As you would expect, scope in LC is always confined to the lowest level, i.e. a handler (on mouseUp, on openCard, etc.), unless you specifically override it using either the local or global keywords. local variables can, at most, have scope within a script (remember, a script is represented by a tab in the Script Editor (a button, field, card, etc.)). global variables can have scope anywhere, but they have to be declared in each script or in each handler or they will not be known to that script or handler.
In any script, there are two ways to declare scope:
a) For the entire script: In the example below, the score variable has scope in the entire script, because it is declared outside of any handler.
Code: Select all
global score #putting it outside of a handler gives it scope in the entire script
on mouseup
...
end mouseUp
on mouseDown
...
end mouseDown
Code: Select all
on mouseup
global score #putting it in the mouseUp handler means it only has scope in the mouseUp handler
...
end mouseUp
on mouseDown
...
end mouseDown
Remember, scope is local to a handler by default. No matter what you do, the only way to access globals in a script is to declare them. A script is a tab in the Script Editor.