MPE/iX Commands Reference Manual (32650-90877)

Appendix B 655
Expression Evaluator Functions
Expression Evaluator Features
calc b*c
49, $31, %61
calc hpresult/a
6, $6, %6
setvar a '2'
setvar b 6
calc a+b
ERROR ** variables of different types **
calc len(b)
ERROR ** expected string or string variable**
calc ord(a)
50, $32, %62
setvar a -6
calc 18/(3^2^3/3^6/3+6)/-(a+3)-1
-1, $FFFFFFFF, %37777777777
The rules of precedence determine which operations are performed before others. Their
order, from highest to lowest priority, is:
Variable dereferencing
Unary operators: + -
Bit manipulation: CSL, CSR, LSL, LSR, BOR, BAND, BNOT, BXOR
Exponentiation
Multiplication, division, modulo
Addition, subtraction
Comparison: > < = + <= <>
Logical operations: AND, NOT
Logical operations: OR, XOR
The evaluation of string expressions follows a similar hierarchy. However, bit
manipulation, multiplication, division, and modulo operations do not apply to string
expressions. If you attempt to use them with a string expression, an error occurs.
Evaluation is left to right until the evaluation is complete, or until a fatal error has been
detected. If a fatal error is detected, evaluation terminates.
Completion of evaluation in this case means either end of expression or partial evaluation
of expression.
In the latter case (partial evaluation), the result of the evaluation can be determined
without examining the rest of the expressions. For example, when part of an expression
that is evaluated to FALSE is followed by an AND, or is evaluated to TRUE and is followed
by an OR:
(1=2) And (2=2 or 3=4)
FALSE And (whatever) -> FALSE
(1=1) or (2=3 and x=y)