pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Table 35 Results of NOT, OR, and AND Operators
ExampleResultOperand TypeOperationOperator
NOT aTrue/FalseSTRING, INT, or
UNSIGNED(1-16)
Negation; tests
condition for false
state
NOT
a OR bTrue/FalseSTRING, INT, or
UNSIGNED(1-16)
Disjunction; produces
true state if either
OR
adjacent condition is
true
a AND bTrue/FalseSTRING, INT, or
UNSIGNED(1-16)
Conjunction; produces
true state if both
AND
adjacent conditions
are true
Topics:
• Evaluating NOT, OR, and AND Operations (page 83)
• NOT, OR, and AND Operators and Condition Codes (page 83)
Evaluating NOT, OR, and AND Operations
NOT, OR, and AND operations are evaluated by means of “short-circuit expression evaluation;”
that is:
• Conditions connected by the OR operator are evaluated from left to right only until a true
condition occurs.
• Conditions connected by the AND operator are evaluated from left to right until a false condition
occurs. The next condition is evaluated only if the preceding condition is true.
In Example 13 (page 83), function f will not be called because a <> 0 is false.
Example 13 Short-Circuit Expression Evaluation
a := 0;
IF a <> 0 AND f(x) THEN ... ;
NOT, OR, and AND Operators and Condition Codes
If the root operator in the conditional expression of an IF statement is a relational operator (<, =,
>, <=, <>, >=, '<', '=', '>', '<=', '<>', '>='), pTAL sets the condition code according to the result
of the comparison.
Relational operators that test the condition code (for example, IF < THEN...) do not set the condition
code.
NOT, OR, and AND operators set the condition code indicator as described in Chapter 13
(page 234).
Relational Operators
• Signed Relational Operators (page 83)
• Unsigned Relational Operators (page 84)
Signed Relational Operators
Signed relational operators perform signed comparison of two operands and return a true or false
state.
Conditional Expressions 83