ciao to all,
a global variable to be accessible to 2 different scripts must be declared in both scripts?
thanks for your attention
franco
Global variables (yet another)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 10053
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Global variables (yet another)
With things like backscripts, libraries, and behaviors, LiveCode is very flexible, and the order of execution of scripts cannot be known by the engine in advance.
To account for this, any globals or constants used must be declared in any script that uses them.
Globals can be declared within a handler that uses them, or outside of any handlers at the top of the script so they're available to all handlers within that script.
Tip: You can also declare local variables outside of handlers, and those are available to all handlers within the script but not to any other script.
To account for this, any globals or constants used must be declared in any script that uses them.
Globals can be declared within a handler that uses them, or outside of any handlers at the top of the script so they're available to all handlers within that script.
Tip: You can also declare local variables outside of handlers, and those are available to all handlers within the script but not to any other script.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Global variables (yet another)
What Richard said,
Note that when declaring script local variables (or globals) they must be declared above any handler within that script in order for those handlers to "see" them.
Craig Newman
Note that when declaring script local variables (or globals) they must be declared above any handler within that script in order for those handlers to "see" them.
Craig Newman
Re: Global variables (yet another)
ciao Richard, ciao Craig.
thank you for solving my doubt. I became crazy to understand why my global variable, declared into script A lost his string into script B.
franco
thank you for solving my doubt. I became crazy to understand why my global variable, declared into script A lost his string into script B.

franco