Problem with declaring local variables

Rob Cozens rcozens at pon.net
Wed Jun 7 10:49:39 EDT 2006


Hi Steve,

> Until now I've had the impression that global variables need to be 
> declared,
> whereas local variables do not.

That depends on whether one wants the value of the local variable to 
persist during runtime:

* An undeclared local variable is initialized to empty every time the 
handler is called.

* A declared local variable is initialized at startup.  Each time a 
handler referencing the variable is called, it contains the value it 
had at the conclusion of the last call.

Also, the scope of undeclared variables is always limited to the 
handler that contains them, whereas the scope of declared [outside the 
handler] local variables encompasses the entire script that declares 
them.  [But only that script: unlike globals, declared local variables 
with the same name in different scripts are different variables.]


Rob Cozens
CCW, Serendipity Software Company

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."




More information about the use-livecode mailing list