MPE/iX Commands Reference Manual (32650-90877)

656 AppendixB
Expression Evaluator Functions
Expression Evaluator Features
TRUE or (whatever) -> TRUE
NOTE
Exponentiation is the one exception to the left-to-right evaluation pattern.
Exponentiation evaluates right to left. For example, 3^2^3 is resolved as 3^8
(=6561) and not as 9^3 (=729).
The logical operators operate only on Boolean expressions, Boolean functions, or Boolean
variables. Boolean expressions are those which contain a comparison operation (<><=>=
<> =) or a logical operation (AND, OR, NOT, XOR).
Examples:
if 6-5>2 and 'abc'-'a'<=rht('cdbc',2) then
EXPRESSION IS FALSE
endif
if not(1=1 and 'a'<>'b') or 6>7 then
EXPRESSION IS FALSE
endif
calc 6+(7>2)
ERROR ** Invalid Expression: **
** Mixed Numeric and Boolean **
if 1 then
ERROR ** Bad Boolean Expression **
setvar errorflag true
if errorflag then
EXPRESSION IS TRUE
endif
The expression evaluator is sensitive to the position of expression tokens. If an operator is
expected, then an operator must be obtained in that position or a fatal error occurs. If a
number is expected and a valid numeric string is not found, variable management is called
to determine if this token is actually a variable. If the token is a variable with a numeric
value, the variable value is used in the expression. If the token is not a variable or the
variable is not an integer variable, the expression is not valid and an error is returned.
If a string is expected and a valid quoted string is not found, variable management is
called to determine if the token is a variable. If it is not a variable, an error is returned. If
it is a variable containing a string value, its contents is used in the expression. If the
variable contains something other than a string, an error is returned.
Provided below is information on other facts you should be aware of concerning evaluator
functions.
Ord
If the length of
string
> 1, then the value returned from ORD(
string
) is the ordinal value
of the first character in the
string
.