Chapter 7. Variables
This chapter describes the rules for declaration, typing, initialization, naming, scoping, and lifetime of variables in the AppleScript language.
A variable is a binding between a name and a value. You can think of it as a shoebox with a label on it, into which something is placed for storage. The shoebox’s label is the variable’s name; what’s inside the shoebox is the variable’s value. For example, when we say:
set x to 5
it is as if we had a shoebox labeled “x” into which we place the number 5.
Assignment and Retrieval
To assign a
value to a variable is to put something into the shoebox. If the
variable already has a value, that value is replaced. Assignment is
performed with one of two commands:
set
or copy
, described
here.
Get AppleScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.