tell me everything u know about global variable
all i know is how to declare them
global thevar
i dont know how to set them of how they work or how to use them
tell me everything u know about global variable
all i know is how to declare them
global thevar
i dont know how to set them of how they work or how to use them
Well, they are set like any other variable:
global gVariable
set gVariable to "my global variable"
I have always found AppleScript’s rules of “variable scope” to be rediculously complicated. They are explained in full in the AppleScript Language Guide, but after 8 years of AppleScripting, I still get lost in trying to work out exactly where AppleScript goes looking for identifiers in the name space:
http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/index.html
In particular:
It’s a lot easier in languages that have simple rules, like:
I’ve learned to avoid globals altogether, not only because they tend to encourage bad programming practice, but also because AppleScript just makes their scoping to complicated to follow. Consider these charts:
Figure 8-1
Scope of property and variable declarations at the top level of a script
Figure 8-2
Scope of property and variable declarations at the top level of a script object
Figure 8-3
Scope of variable declarations within a handler