On your second point, do you mean a declared local variable OUTSIDE a
handler? I think you are confusing a declared local variable INSIDE a
handler with one that is declared OUTSIDE a handler.
I don't believe one declare INSIDE a script retains its value:
local sRetainsValue = 0
on AddOne
add 1 to sRetainsValue
put sRetainsValue
end AddOne
on AddHandler
local tDoNotRetainValue = 0
add 1 to tDoesNotRetainValue
put tDoesNotRetainValue
end AddHandler
If you call AddOne, you will get 1, 2, 3, etc.
If you call AddHandler, you will always get 1.
There is a difference between SCRIPT local, which must be declared, and
HANDLER local, which is optionally declared (unless explicitVariables is
true). If a variable is not declared outside a handler, it is assumed to
be a handler local variable and reinitialized every time the handler is called.
At 09:49 AM 6/7/2006, you wrote:
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."
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Peter T. Evensen
http://www.PetersRoadToHealth.com
314-629-5248 or 888-682-4588
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution