COBOL Manual for TNS and TNS/R Programs

Procedure Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
8-68
Condition Evaluation Rules
Examples of abbreviated combined and negated relation conditions and expanded
equivalents:
Condition Evaluation Rules
Parentheses can be used to specify the order in which individual conditions are to be
evaluated when it is necessary to depart from the implied evaluation precedence.
Conditions within parentheses are evaluated first. Within nested parentheses,
evaluation proceeds from the least inclusive condition to the most inclusive condition.
When parentheses are not used, or parenthetical conditions are at the same level of
inclusiveness, this hierarchical order of logical evaluation is implied until the final truth
value is determined:
Values are established for arithmetic expressions.
Truth values for simple conditions are established in this order:
°
Relation
°
Class
°
Condition-name
°
Switch-status
°
Sign
Truth values for negated simple conditions are established.
Truth values for combined conditions are established, first by applying the AND
logical operators, then by applying the OR logical operators.
Truth values for negated combined conditions are established.
When the sequence of evaluation is not completely specified by parentheses, the
order of evaluation of consecutive operations of the same hierarchical level is from
left to right.
Abbreviated Combined Relation
Condition Expanded Equivalent
A > B AND NOT < C OR D ((A > B) AND (A NOT < C)) OR (A NOT < D)
A NOT EQUAL B OR C (A NOT EQUAL B) OR (A NOT EQUAL C)
NOT (A GREATER B OR < C) NOT ((A GREATER B) OR (A < C))
NOT (A NOT > B AND C AND NOT D) NOT ((((A NOT > B) AND (A NOT > C)) AND
(NOT (A NOT > D))))
(A + B - C) > D AND NOT < E OR F (A + B - C) > D AND (A + B - C) NOT < E OR
(A + B - C) NOT < F