Generic Invisibility Handler
bobs at twft.com
Mon Feb 8 12:56:54 EST 2010
There are two ways to make a variable visible to a command or function. First, you can declare the variable as a global or script local. A global variable is one that is available to any handler that declares it, or optionally, to any script that declares it outside any handlers:
The second way is to pass the value to the command or function:
on doAnotherthing myValue
-- some commands
The globals or script locals are persistent while Revolution is running. The parameter is NOT persistent, in that as soon as doAnotherThing terminates, myValue is destroyed.
You could make it a function:
function doYetAnotherThing myValue
-- do things that change myValue
and then preserve myValue by putting the result of the function back into myValue:
put doYetAnotherThing(myValue) into myValue
Seems silly, but there you have it. The better way to do this without using a function is by declaring the parameter using the @ keyword (keychar??):
on doOneLastThing @myValue
-- some commands that change myValue
in which case myValue will not be destroyed when doOneLastThing terminates, because the command was passed to the function as a variable and not the value. The calling program will see the change in myValue.
That about sums it up. Globals and Script Locals are for persistence while Revolution is running. They are visible to whatever declares then, including ALL handlers in a script that declares it outside of any handler like so:
local myValue -- or global if you want it to be visible by ALL handlers
-- in ALL scripts in your stack or application
-- do something to the most used variable ever
Parameters are for passing values that get destroyed when the command or function terminates.
On Feb 8, 2010, at 9:14 AM, Andrew Kluthe wrote:
> Any suggestions on helping this RevNub get this sorted out? In your
> response, try to include how the params are used in handlers. Thank you so
> much in advance for your replies!
More information about the Use-livecode