Language Guide
CHAPTER 6
Expressions
Operations 161
When AppleScript executes the statement, it gets the value of the reference
word 1 of front document of application "Scriptable Text
Editor"—a string—and then coerces it to an integer, if possible. (For
information about the Repeat statement, refer to Chapter 7, “Control
Statements.” For information about coercions, refer to “Coercing Values”
on page 68.)
Operations 6
Operations are expressions that use operators to derive values from other
values. AppleScript includes operators for performing arithmetic operations,
comparing values, performing Boolean evaluations, and coercing values.
The values from which operators derive values are called operands. Each
operator can handle operands of specific classes, which are defined in the
definition of the operator. For example, the operands for the addition (+)
operator must belong to the class Integer or Real, while the operand for the
Not operator must belong to class Boolean. Certain operators work with
operands from a variety of classes. For example, you can use the concatenation
operator (&) to join two strings, two lists, or two records.
The result of each operation is a value of a particular class. For many operators,
such as the equality operator (=) and the greater than operator (>), the class of
the result is always the same—in these cases, Boolean. For other operators,
such as the concatenation operator (&), the class of the result depends on the
class of the operands. For example, the result of concatenating two strings is a
string, but the result of concatenating two integers is a list of integers.
If you use an operator with operands of the wrong classes, AppleScript
attempts to coerce the operands to the correct class, if possible. For example,
the concatenation operator (&) works with strings, lists, or records. When
AppleScript evaluates the following expression, it coerces the integer 66 to a
string before concatenating it with the string "Route".
"Route " & 66
--result: "Route 66"