LOTUSSCRIPT LANGUAGE
To override the normal order of evaluation in an expression, use parentheses. Subexpressions in parentheses are evaluated before the other parts of the expression, from left to right.
The following table summarizes the order of operator precedence. The operands in the table are binary except where noted. Operators on the same line have the same precedence. In order of highest-to-lowest, the precedence of LotusScript operators is:
This example shows the order of precedence for Arithmetic operators.
Print 6 + 4 / 2 ' Prints 8 Print (6 + 4) / 2 ' Prints 5
Print -2 ^ 2 ' Prints -4 Print (-2) ^ 2 ' Prints 4
This example shows the order of precedence for Comparison operators:
Print 5 < 3 ' Prints False Print 5 > 3 ' Prints True
Print "Alphabet" = "Alpha" & "bet" ' Prints True
Print 4 And 10 - 2 * 3 / 2 ' Output: 4 because 2 * 3 = 6 ' 6 / 2 = 3 ' 10 - 3 = 7 (binary 111) ' 4 (binary 100) And 7 (binary 111) = 4 (binary 100).
You can alter the default order in which operations are performed by enclosing the expressions you want evaluated first in parentheses.
For example:
anInt% = 5 anotherInt% = 10 aThirdInt% = 7 print anInt% - (anotherInt% + aThirdInt%) ' Output: -12
or, alternatively:
theResult% = -1 Or -1 Imp 0 Print theResult% ' Output: False ' because -1 Or -1 = True, and True Imp 0 is False. theResult% = -1 Or (-1 Imp 0) Print theResult% ' Output: True ' because -1 Imp 0 is False, and -1 Or False is True.
A function is evaluated before any of the operators in an expression.
Print -1 > 0 ' Output: False Print Abs(-1) > 0 ' Output: True
See Also