Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 6 - Expressions / Variables


Scope of Variables

The scope of a variable determines where else in a script you may refer to the same variable. The scope of a variable in turn depends on where you declare it and whether you declare it as global or local.

After you define a global variable in a script, you can make subsequent references to the same variable either at the top level of the script or in any
of the script's subroutines. After you define a local variable, you can make subsequent references to the same variable only at the same level of the script at which you defined the variable.

AppleScript assumes that all variables defined at the top level of a script or within its subroutines are local unless you explicitly declare them as global. For more detailed information and examples of the use of variables in subroutines, see "Recursive Subroutines," which begins on page 225.

You can also declare variables within script objects. The scope of variables in a script object is limited to that script object. For more information, see "Scope of Script Variables and Properties," which begins on page 252.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996