Don't understand the meaning of "local"
Alex Tweedly
alex at tweedly.net
Fri Dec 23 19:05:17 EST 2005
Mark Wieder wrote:
>Jim-
>
>Well, I spoke too soon.
>
>If I have a global variable "gBlnChkCase" I can say
>put "gBlnChkCase" is among the items of the globalNames
>and I get a return value of true.
>
>But issuing a "delete global gBlnChkCase" or delete global
>gBlnChkCase" from the message box returns "Script compile error: Error
>description: delete: bad variable expression".
>
>So I think, OK, maybe that global isn't really sitting out there in
>memory space waiting to ambush me. But trying to compile the line
>local gBlnChkCase
>gives a compile error of "local: name shadows another variable or
>constant".
>
>It seems to me that "delete global" doesn't.
>
>
>
Although a global variable is global, it isn't "in scope" in a script
unless it is declared as global within that script.
This is true for the message box, just as for any other script.
So simply saying "delete global gVar" will give you an error; what you
need to do is
global gVar; delete global gVar
Weird, huh ? But it works.
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.5/212 - Release Date: 23/12/2005
More information about the use-livecode
mailing list