Expression Limitations

The operators provided by the macro language can only be used one at a time unless you surround nested expressions in parentheses (this enhancement was added for v2.1). That is, parentheses allow the user of multiple operators in a single command. This assignment is valid:

$result = $apples + $oranges

But this is not valid:

$result = $apples + $oranges * 10 # error

To accomplish the calculation you would either have to break the expression down:

$fruits = $apples + $oranges

$result = $fruits * 10

Or use parentheses:

$result = ($apples + $oranges) * 10

Parentheses are not needed for chained text concatenation, or a calculation involving just addition and subtraction:

$count = $apples + $oranges + $cherimoyas

$place = "Solana Beach"

$message = "There are " & $count & " fruits in " & $place & "."

You may use operators in arguments for commands or object properties, eg:

Prompt $apples + $oranges

Prompt ($apples + $oranges) / 2
Prompt $basket.valueAtIndex($index + 2)


Previous Chapter
Boolean Operators
<<  index  >>
 
Next Chapter
Type Commands