JSL also provides operators for in-place arithmetic, or assignment operators. These operations are all done in place, meaning that the result of the operation is assigned to the first argument. The most basic assignment operator is the = operator (or the equivalent function Assign). For example, if a is 3 and you do a+=4, then a becomes 7.
The first argument to an assignment function must be something capable of being assigned (an L-value). You cannot do something like 3+=4, because 3 is just a value and cannot be reassigned. However, you can do something like a+=4, because a is a variable whose value you can set.
Adds a and b and places the sum into a.
For Add To(): Only two arguments are permitted. If one or no argument is specified, Add To() returns a missing value. Any arguments after the first two are ignored.
For a+=b: More than two arguments can be strung together. JMP evaluates pairs from right to left, and each sum is placed in the left-hand variable. All arguments except the last must be a variable.
JMP adds b and c and places the sum into b. Then JMP adds a and b and places the sum into a.
List Operators in the Scripting Guide.
a must be a variable, because it must be able to accept a value change. A number as the first argument produces an error. If b is some sort of expression, it’s evaluated first and the result is placed into a.
Divides a by b and places the result into a.
List Operators in the Scripting Guide.
Multiplies a and b and places the product into a.
For Multiply To(): Only two arguments are permitted. If one or no argument is specified, Multiply To() returns a missing value. Any arguments after the first two are ignored.
For a*=b: More than two arguments can be strung together. JMP evaluates pairs from right to left, and each product is placed in the left-hand variable. All arguments except the last must be a variable.
a*=b*=c
JMP multiplies b and c and places the product into b. Then JMP multiplies a and b and places the product into a.
List Operators in the Scripting Guide.
Post-decrement. Subtracts 1 from a and places the difference into a.
If a-- or Post Decrement(a) is inside another expression, the expression is evaluated first, and then the decrement operation is performed. This expression is mostly used for loop control.
Post-increment. Adds 1 to a and places the sum into a.
If a++ or PostIncrement(a) is inside another expression, the expression is evaluated first, and then the increment operation is performed. Mostly used for loop control.
Subtracts b from a and places the difference into a.
For SubtractTo(): Only two arguments are permitted. If fewer than two or more than two arguments is specified, SubtractTo() returns a missing value.
For a-=b: More than two arguments can be strung together. JMP evaluates pairs from right to left, and each difference is placed in the left-hand variable. All arguments except the last must be a variable.
a-=b-=c
JMP subtracts c from b and places the difference into b. Then JMP subtracts b from a and places the difference into a.
List Operators in the Scripting Guide.