About variable.

Dan Shafer revdan at danshafer.com
Thu Mar 31 00:07:57 EST 2005


Just precede its name with the word "global":

global gMyVariable, gMyOtherVariable

(The "g" before the name is not required, but it is considered an 
optional "best practice" because it makes it easier to remember which 
variables are global when you use them in your programs.)

You can put this declaration in a script completely outside any 
handlers and make it a script global:

global gMyVariable, gMyOtherVariable

on mouseUp
   -- do something
   put "some stuff" into gMyVariable
end mouseUp

on someHandler
   -- do something
   put "some other stuff" after gMyVariable
end someHandler

Or you can define the global(s) inside all of the handlers where you 
want to use them:

on mouseUp
   global gMyVariable, gMyOtherVariable
   -- do something
   put "some stuff" into gMyVariable
   put "some other stuff" into gMyOtherVariable
end mouseUp

on someHandler
   global gMyVariable, gMyOtherVariable
   -- do something
   put "more stuff" into item 2 of gMyVariable
   put ", still more stuff" after gMyOtherVariable
end someHandler


On Mar 30, 2005, at 8:52 PM, Kevin J wrote:

> How do you make a variable global so that you can use it though out 
> the program?
>
> Thanks
> Kevin
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dan Shafer, Co-Chair
RevConWest '05
June 17-18, 2005, Monterey, California
http://www.altuit.com/webs/altuit/RevConWest



More information about the use-livecode mailing list