[Contents] [Prev] [Next] [Index] [Report an Error]

Increment and Decrement

You can use the increment operator (++) to increase the value of a local variable by one. You specify when the value is incremented by the placement of the operator. Incrementing occurs after the expression is evaluated if you place the operator to the right of the operand. Incrementing occurs before the expression is evaluated if you place the operator to the left of the operand.

Example 1

<# i := 0; j := 10 #>
<# j := j - i++ #>

In Example 1, the result is that i equals 1 and j equals 10, because the expression is evaluated (10 – 0 = 10) before i is incremented.

Example 2

<# i := 0; j := 10 #>
<# j := j - ++i #>

In Example 2, the result is still that i equals 1, but now j equals 9, because i is incremented to 1 before the expression is evaluated (10 – 1 = 9).

Similarly, you can use the decrement operator (– –) to decrement local variables. Placement of the operator has the same effect as for the increment operator.

When a local variable with a string value is used with the increment or decrement operators, the value is permanently converted to an integer equal to the length in characters of the string value.


[Contents] [Prev] [Next] [Index] [Report an Error]