Section 10.2. Kinds of Variable


10.2. Kinds of Variable

With regard to scope, we must distinguish four kinds of variable:


Top-level entities

Top-level entities are script properties declared, and script objects and handlers defined, at the top level of a script or script object. (See "Top-Level Entities" in Chapter 8.)


Explicit locals

An explicit local is a variable announced by a local declaration , which looks like this:

 local x


Explicit globals

An explicit global is a variable announced by a global declaration, which looks like this:

 global x


Undeclared variables

A undeclared variable is none of the above. It's just a name that your code suddenly starts using. This is legal, but when you do it, AppleScript assigns the variable a scope , in ways that may surprise you.

The scope of a variable, and what kind of variable it is (these amount to the same thing), are determined at compile time .




AppleScript. The Definitive Guide
AppleScript: The Definitive Guide, 2nd Edition
ISBN: 0596102119
EAN: 2147483647
Year: 2006
Pages: 267
Authors: Matt Neuburg

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net