COBOL Manual for TNS and TNS/R Programs

Procedure Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
8-7
Statements
Compare Example 8-3 to Example 8-4.
Delimited-Scope Statement
A delimited-scope statement is any statement that terminates in its explicit scope
terminator. An explicit scope terminator is a reserved word used to delimit the scope of
a conditional statement or in-line PERFORM statement.
The form of each explicit scope terminator includes the verb from the statement that it
terminates. Explicit scope terminators can appear only as specified in the general
formats for statements. When the appropriate explicit scope terminator follows a
conditional statement, it is considered to be a delimited-scope statement instead.
In Example 8-4, if there were no END-READ scope terminator, the PERFORM would
be part of the AT END phrase of the (conditional) READ statement.
Under the rules for statement execution, a delimited-scope statement is handled in the
same manner as a conditional statement. This is because it can include phrases that
are or are not executed depending upon the value of a condition (for example, the
delimited-scope IF statement) or upon the occurrence of an exception (for example,
the delimited-scope READ statement).
Example 8-3. Conditional Statement
IF NOT DONE-WITH-MASTER
READ MASTER-FILE
AT END MOVE DONE-VALUE TO MASTER-FLAG.
Table 8-4. Explicit Scope Terminators
END-ADD END-EVALUATE END-RETURN END-SUBTRACT
END-CALL END-IF END-REWRITE END-UNSTRING
END-COMPUTE END-MULTIPLY END-SEARCH END-WRITE
END-DELETE END-PERFORM END-START END-UNSTRING
END-DIVIDE END-READ END-STRING
Example 8-4. Delimited-Scope Statement
IF NOT DONE-WITH-MASTER
READ MASTER-FILE
AT END MOVE DONE-VALUE TO MASTER-FLAG
END-READ
PERFORM PROCESS-MASTER-RECORD
UNTIL DONE-WITH-MASTER
END-IF