HP 3000 Manuals

Condition Evaluation Rules [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

Condition Evaluation Rules 

You may use parentheses to specify the order in which individual
conditions of complex conditions are to be evaluated when you wish to
modify the precedence rules (as listed below) for evaluating such
conditions.

Conditions within parentheses are evaluated first.  Within nested
parentheses, the condition bounded by the innermost set is evaluated
first, followed by the condition within the next innermost set.  The
process continues until the condition within the outermost set of
parentheses is evaluated.

When parentheses are not used, or when they completely contain a
condition, the following rules (in the order listed) are used to
determine the truth value:

   1.  The order of precedence of logical operators is NOT, AND, OR. The
       order of precedence establishes hierarchical levels of conditions
       at the same precedence level.

   2.  Conditions in the same hierarchical level are evaluated from left
       to right.  Evaluation of that level terminates as soon as a truth
       value for the level is determined, regardless of whether all the
       constituent conditions within that level have been evaluated.

   3.  Values are established for arithmetic expressions if and when it
       is necessary to evaluate them.

   4.  Negated conditions are evaluated if and when it is necessary to
       evaluate them.

Application of the above rules is illustrated in Figure 8-1  through
Figure 8-4  on the following pages.

[]
Figure 8-1. Evaluation of the hierarchical level condition-1 and condition-2 and...condition-n
[]
Figure 8-2. Evaluation of the hierarchical level condition-1 or condition-2 or...condition-n
[]
Figure 8-3. Evaluation of condition-1 or condition-2 and condition-3
[]
Figure 8-4. Evaluation of (condition-1 or not condition-2) and condition-3 and condition-4


MPE/iX 5.0 Documentation