Strict Compile Mode

Guglielmo Braguglia guglielmo at
Fri Oct 12 02:37:09 EDT 2012

Hi Pete,

if you declare a variable "global",the variable IS GLOBAL FOR ANY STACK 
and is "*persistent*". This means that the variable and its value exist 
regardless of the stack that created. If you liketo see do just a simple 
test ...

... create a stack and from this stack create a "global" variable and 
put something inside. Close and destroy the stack. Open a new stack 
andopen the Editor window (e.g. start writing a script). On the bottom 
select the TAB "Variables" and ... your old global is there with its 
value :-)

And YES, this can create problem if you don't close LiveCode between the 
developmentof two different projects because some "globals" of one 
project can collide with some variable of another project (e.g. a local 
with the same name).

"local" variables have a different behavior depending on where you 
declare them...
... if you declare "inside" an handler they live long the handler lives, 
but if you declare at the beginning of your script, before the handlers, 
they become like "locals global" ... exist and retain their value (ONLY 
inside the script where they are declared) until the program exist.
If you close and destroy the main stack ... they are removed.
If you like to see do another simple test ...

... create a stack and create different scripts (e.g. some scriptfor 
some buttons). On the different scripts define "local" variable on the 
TOP of the script, before handlers. Assigns them a value. Now, if you 
insert some breakpoints (on the different scripts) you will see, still 
looking into the "Variables" TAB, that, when the script stop because 
reach the breakpoint (so the script is the current script), you will 
find the local variable of the script with the correct value.

Please note that, also if this rules remain valid, the behavior of 
LiveCode is different if your "Strict Compile Mode" is ON or OFF !!! ... 
and this creates more confusion !!!

With "Strict Compile Mode" ON ... you are obliged to declare the 
variable and LiveCode verify the "collisions" and give you error if one 
local have the same name of a global, BUT, if "Strict Compile Mode" is 
OFF, LiveCode don't verify the "collisions" and the same variable can be 
a local or a global depending on whether you declare it "global" or not 
:o ... and this is really ridiculous !!!

Hope this clarify the situation ... :-)


On 12.10.2012 00:26, Peter Haworth wrote:
> It's definitly true if you want to refer to it as a global when the script
> runs, I agree.  But I got the impression from Mark's post that perhaps the
> compile process (or I guess more correctly the Apply process) recognises
> globals that have been defined in other scripts and not in the current one,
> that's really what my question is about.
> Pete
> lcSQL Software <>
> On Thu, Oct 11, 2012 at 3:03 PM, Bob Sneidar <bobs at> wrote:
>> I don't think that is true Pete. I think you DO have to define a global,
>> either in the script or in the handler in order for it to be treated as
>> such. What is causing the shadow variable glitch I don't know.
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

More information about the Use-livecode mailing list