global variables
Rob Cozens
rcozens at pon.net
Mon Aug 26 06:18:00 EDT 2002
>One can define local variables that are shared by all handlers in a script
>and whose values persist until the stack is closed.
One last note: although declared locally in one script, local
variables in a stack script can be read and changed anywhere in the
stack by providing get and set handlers. If the stack is a library,
the variables can be read and changed by handlers in other stacks as
well. Example stack script --
local pseudoGlobal
-- stack handlers that use pseudoGlobal internally
on addPG aNumber
add aNumber to pseudoGlobal
end addPG
on subtractPG aNumber
subtract aNumber from pseudoGlobal
end subtractPG
-- stack handlers that allow access to pseudoGlobal outside the stack script
function getPG
return pseudoGlobal
end getPG
on setPG theValue
put theValue into pseudoGlobal
end setPG
--
Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm
"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
mailing list