COBOL Manual for TNS and TNS/R Programs

Procedure Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
8-6
Statements
Conditional Statement
A conditional statement specifies that the truth value of a condition is to be determined
and that the subsequent action of the run unit depends on this truth value.
Any of these statements is a conditional statement (unless it ends with an explicit
scope delimiter):
An EVALUATE, IF, RETURN, or SEARCH statement
A READ statement with the AT END or INVALID KEY phrase
A WRITE statement with the INVALID KEY or END-OF-PAGE phrase
A DELETE, REWRITE, or START statement with the INVALID KEY phrase
An arithmetic statement (ADD, COMPUTE, DIVIDE, MULTIPLY, or SUBTRACT)
with the SIZE ERROR phrase
A STRING or UNSTRING statement with the OVERFLOW phrase
A CALL statement with the EXCEPTION phrase (or the OVERFLOW phrase,
which is obsolete for the CALL statement)
The NOT AT END, NOT INVALID KEY, NOT END-OF-PAGE, NOT SIZE ERROR, and
NOT EXCEPTION phrases also make their parent statement a conditional statement.
There is no NOT OVERFLOW phrase.
Any conditional statement can be preceded by an imperative statement or any
sequence of statements specified as equivalent to an imperative statement by the rules
given in Imperative Statement.
Unless it is contained within an IF statement, a conditional statement must be the last
or only statement in a sentence; however, any statements listed previously can be
written as a delimited-scope statement. For clarity and convenience, you are
encouraged to avoid conditional statements entirely and use equivalent delimited-
scope statements instead.
In Example 8-3, the period ends both the IF and the AT END phrase. If there were an
operation that the program had to perform after the read operation succeeded, but only
when DONE-WITH-MASTER was false, you would have to package the READ
statement in a separate paragraph. Then you could end the AT END phrase with a
period that did not also end the IF statement.
Example 8-2. Imperative Statement
MOVE "Birnham Wood" TO DUNSINANE