COBOL Manual for TNS and TNS/R Programs
Procedure Division
HP COBOL Manual for TNS and TNS/R Programs—522555-006
8-17
Sentence Execution
The compiler-directing statements COPY, REPLACE, and USE do not participate in
execution; therefore, control is never transferred to or from these statements.
Sentence Execution
A sentence containing only imperative statements is always executed in its entirety.
Normally, control then passes to the next sentence in the paragraph that contains an
imperative or conditional statement. Exceptions to this rule are:
•
When the last statement in the sentence is a GO TO statement, control is
transferred unconditionally to the specified paragraph or section.
•
When the last statement in the sentence is a STOP RUN statement, execution of
the run unit, and thus the program, terminates.
•
When the last statement in the sentence is an EXIT PROGRAM statement, control
is transferred in accordance with the rules for that statement.
If the sentence is not followed within its paragraph by any other sentence that contains
an imperative, conditional, or delimited-scope statement, and none of the preceding
cases applies, then control passes to the first executable sentence in another
paragraph. The paragraph to which control passes is determined by the rules
described under Paragraph Execution.
A sentence containing a conditional or delimited-scope statement is not necessarily
executed in its entirety. After executing any initial imperative statements, the execution
of the conditional or delimited-scope statement causes the object program to select the
appropriate path of control.
Control is never transferred to or from sentences that consist of a compiler-directing
statement.
Paragraph Execution
Execution of a paragraph begins with the execution of the first sentence containing an
imperative, conditional, or delimited-scope statement. Except for the nested execution
of other procedures or programs (for example, by the execution of PERFORM or CALL
statements) control remains within the paragraph until either:
•
The execution of a GO TO, STOP RUN, or EXIT PROGRAM statement transfers
control out of the paragraph.
•
The final executable sentence of the paragraph completes without explicitly
transferring control to some other procedure. In this case, control passes to the
next paragraph of the same section if one exists or to the next section in the source
program, except in these situations:
1. The rules for the implicit transfer of control among procedures, described later,
can cause control to revert to some other paragraph or section instead.
2. If no such reversion occurs, and no next section exists, execution of the
program terminates.