Language Guide
CHAPTER 6
Expressions
Operations 179
You can change the order in which AppleScript performs operations by
grouping expressions in parentheses. As shown in Table 6-2, AppleScript
evaluates expressions in parentheses first. For example, adding parentheses
around 5 + 12 in the following expression causes AppleScript to perform the
addition operation first and changes the result.
2 * ( 5 + 12 )
--result:34
Table 6-2 Operator precedence
Order Operators Associativity Type of operator
1
( )
Innermost to
outermost
Grouping
2
+
-
Unary Plus or minus sign for numbers
3
^
Right to left Exponentiation
4
*
/
div
mod
Left to right Multiplication and division
5
+
-
Left to right Addition and subtraction
6
as
Left to right Coercion
7
<
>
None Comparison
8
=
None Equality and inequality
9
not
Unary Logical negation
10
and
Left to right Logical for Boolean values
11
or
Left to right Logical for Boolean values