HP 3000 Manuals

Complex Conditions [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

Complex Conditions 

A complex condition is formed by using the logical operators AND and OR
to combine simple, combined, and/or complex conditions, or by negating
these conditions with the logical negation operator, NOT.

The truth value of a complex condition, regardless of the use of
parentheses, results from the interaction of all the stated logical
operators on the individual truth values of simple conditions.  It can
also be the result of the intermediate truth values of conditions
logically connected or negated.

The meanings of the three logical operators are listed below.

Logical Operator    Meaning                                                                                                          

AND                 Logical conjunction; the truth value is "true" if
                    both of the conjoined conditions are true and "false"
                    if one or both of the conjoined conditions is false.

OR                  Logical inclusive OR; the truth value is "true" if
                    one or both of the included conditions is true and
                    "false" if both included conditions are false.

NOT                 Logical negation or reversal of truth value; the
                    truth value is "true" if the condition is false and
                    "false" if the condition is true.

When a logical operator is used, it must be preceded and followed by a
space.

Combined Conditions 

You can form a combined condition by connecting conditions with one of
the logical operators, AND or OR. Combined conditions have the following
format:

[]
Parameter condition-1 where condition-1 is one of five possible types of conditions: * A simple condition. * A negated simple condition. * A combined condition. * A negated combined condition (combined condition enclosed by parentheses and preceded by the NOT logical operator). * Combinations of any of the four types listed above, as specified in Table 8-4 . Although you do not need parentheses when you form a combined condition using AND or OR, you may use parentheses to clarify and to affect the final result of a combined condition. Table 8-4 indicates the ways in which conditions and logical operators can be combined and parenthesized. There must be a one-to-one correspondence between left and right parentheses. Any left parenthesis must be to the left of its corresponding right parenthesis. As an illustration of the use of the table, note that the pair OR NOT is acceptable, whereas NOT OR is not acceptable. Table 8-4. Valid Combinations of Conditions, Logical Operators, and Parentheses ----------------------------------------------------------------------------------------------------- | | | | | | Location in | In a left-to-right sequence of | | | conditional | elements: | | | expression | | | Given the | | | | following | | | | element: | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | | | | Element, when not | Element, when not | | | | | first, | last, | | | | | may be | may be | | | | | immediately | immediately | | | | | preceded by only: | followed by only: | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | | First | Last | | | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | simple-condition | Yes | Yes | OR, NOT, AND, ( | OR, AND, ) | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | OR or AND | No | No | simple-condition, | simple-condition, | | | | | ) | NOT, ( | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | NOT | Yes | No | OR, AND, ( | simple-condition, | | | | | | ( | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | ( | Yes | No | OR, NOT, AND, ( | simple-condition, | | | | | | NOT, ( | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | ) | No | Yes | simple-condition, | OR, AND, ) | | | | | ) | | | | | | | | ----------------------------------------------------------------------------------------------------- Negated Simple Conditions The NOT operator can be used to negate simple conditions. A negated simple condition has a value of "true" only if the value of the simple condition is "false". Conversely, a negated simple condition has a value of "false" only if the simple condition itself has a value of "true". Negated simple conditions have the following format: NOT condition-1 Parameter condition-1 where condition-1 is one of five possible types of conditions: * A simple condition. * A negated simple condition. * A combined condition. * A negated combined condition (combined condition enclosed by parentheses and preceded by the NOT logical operator). * Combinations of any of the four types listed above, as specified in Table 8-4 . Example IF CON-NAME1 THEN PERFORM UNDER-VALUE ELSE NEXT SENTENCE. is equivalent to: IF NOT CON-NAME1 THEN NEXT SENTENCE ELSE PERFORM UNDER-VALUE.


MPE/iX 5.0 Documentation