Test Variable?

Phil Davis davis.phil at comcast.net
Fri Feb 10 19:45:26 EST 2006


Thanks for the extension & clarification Jim - I left this out of my 
explanation.

Phil


Jim Ault wrote:
> On 2/10/06 3:37 PM, "Phil Davis" <davis.phil at comcast.net> wrote:
>  
> 
>>When you declare a global within a handler, the data that goes into it
>>will stay there, but no other handler can access it - the place where
>>you declare a variable determines its scope. Put the "global" statement
>>at the top of your script, outside of all handlers; then all handlers in
>>that script can access it.
>>
>>If your 'openField' handler is in a different script (like of a field),
>>then that script will also need to contain a "global varCmdLineParamIn"
>>statement for the var to be accessible there.
> 
> 
> Actually, 
> * no other handler can access it * is not correct.
> Declaring a global anywhere creates it in the Rev app.  It is live until you
> quit Rev or do "delete global gComputerName"
> 
> --example
> on doThisStep
>   global gComputerName
>   put "Fred" into gComputerName
> end doThisStep
> 
> --at this point, the Rev app has control over the global gComputerName and
> any stack or handler can access this global by doing
> 
> on buildMyString
>   global gComputerName
>   put "Working on " & gComputerName into stringToWrite
> end buildMyString
> 
> 
> Declaring the global in any handler will give that handler access to it.
> The confusion comes in when you consider that the following:
> 
> --top of stack script
> global gComputerName
> 
> --now means that any handler in this script has access to the global without
> having to declare it.  Of course, declaring it again in a handler makes it
> appear in the Variable Watcher twice (or more in 2.6.1 Mac) so you should
> only declare the globals one time.
> 
> Hope this helps
> 
> Jim Ault
> Las Vegas
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 




More information about the Use-livecode mailing list