COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Table 55 Conditions, Logical Operators, and Parentheses
In a left-to-right sequence of elementsLocation in
Conditional
Expression
When not last, element can be
immediately followed only by
When not first, element can be
immediately preceded only by
LastFirstElement
AND, OR, )AND, NOT, OR, (YesYessimple-condition
NOT, (, simple-conditionsimple-condition, )NoNoAND or OR
(, simple-conditionAND, OR, (NoYesNOT
NOT, (, simple-conditionAND, NOT, OR, (NoYes(
AND, OR, )simple-condition, )YesNo)
As Table 55 shows, you can use the element pair OR NOT, but you cannot use the pair NOT OR.
Also, you can use NOT, but you cannot use NOT NOT. Within the combined condition, parentheses
must always be in balanced pairs, so that each left parenthesis precedes its corresponding right
parenthesis.
These combined conditions are valid:
All four are condition-names—level-number 88.LARRY AND MOE AND (CURLY OR SHEMP)
All three symbols are alphanumeric data items.I < E AND (E NOT > C)
Both A and B are numeric data items.NOT ((A IS POSITIVE) OR (B IS POSITIVE))
Abbreviated Combined Relation Conditions
COBOL enables you to abbreviate a sequence of complex relation conditions. For example, you
can use
A NOT EQUAL B OR C
instead of having to use
(A NOT EQUAL B) OR (A NOT EQUAL C)
You can abbreviate any condition in a sequence except the first one by omitting either of these:
• The subject, for example:
A NOT EQUAL B OR NOT EQUAL C
• The relational operator and the subject, for example:
A NOT EQUAL B OR C
The subject is the term to the left of the operator. For more information, see Usage Considerations.
rel-condition
is a relational condition.
274 Procedure Division










