Global variables & multiple stacks
rcozens at pon.net
Mon Apr 14 11:05:01 CDT 2003
>What happens if I have identical global variables that I've
>accidentally used in both (previously separate) stacks? Are global
>var's truly global in that the data they hold are shared among all
Once a global variable is declared to the MC engine, ALL stacks (not
just substacks of the main stack) that reference that global will
access the same address in RAM, and global values will persist until
the engine quits.
>Are there variable types that are only "global" to a stack?
"Global" to all handlers in all controls on all cards...no.
However any declared local variable (eg: local myPseudoGlobal) in a
script is available to all handlers declared after it in the same
script; so myPseudoGlobal declared as the first line of a stack
script is now "global" to every handler in the stack script.
Taking it one step further, one can give handlers in other controls
access to the variable by placing getVariable & setVariable handlers
in the stack script:
on setMyPseudoVariable newValue
put newValue into myPseudoVariable
myPseudoGlobal is now available to every control in the stack (and
beyond, if it's in the script of a stack in use), albeit one must use
the get & set functions in handlers outside of the stack script.
CCW, Serendipity Software Company
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode