Variable Scoping

Mark Wieder mwieder at
Mon Oct 9 13:34:01 EDT 2006


Friday, October 6, 2006, 9:18:40 PM, you wrote:

> Am I correct in stating that variables in a custom command are not  
> visible to other commands and functions that it calls? In other  
> words, if I put "blah" into bobtest in handler "dosomething" and then
> "dosomething" calls handler "somethingelse", is bobtest invisible to
> handler "somethingelse"? Is there any way to change this behavior? If

Sounds like you need to get used to the idea of variable scoping.

There are several ways to accomplish what you want, if I understand
this correctly. One is to declare your variables outside the handlers
in the the object, card, or stack script. Another is to use custom
properties as containers for your variable information. A third would
be to define accessor functions for the variables you wish to make
available to other scripts. An option of last result would be to make
some variables global so that they are available from any script. And
probably there are other ways to deal with this that I haven't thought
of off the top of my head...

-Mark Wieder
 mwieder at

More information about the Use-livecode mailing list