The GO TO statement transfers control from one part of the procedure division to another. The types of GO TO statements are:
The unconditional GO TO statement transfers control to the first statement in the paragraph or section identified by procedure-name, unless the GO TO statement has been modified by an ALTER statement. (See ALTER statement.)
Format 1: unconditional GO TO statement >>-GO--+----+--procedure-name-1-------------------------------->< '-TO-'
When the unconditional GO TO statement is not the last statement in a sequence of imperative statements, the statements following the GO TO are not executed.
When a paragraph is referred to by an ALTER statement, the paragraph must consist of a paragraph-name followed by an unconditional or altered GO TO statement.
The conditional GO TO statement transfers control to one of a series of procedures, depending on the value of the data item referenced by identifier-1.
Format 2: conditional GO TO statement .------------------. V | >>-GO--+----+----procedure-name-1-+--DEPENDING--+----+----------> '-TO-' '-ON-' >--identifier-1------------------------------------------------><
If 1, control is transferred to the first statement in the procedure named by the first occurrence of procedure-name-1.
If 2, control is transferred to the first statement in the procedure named by the second occurrence of procedure-name-1, and so forth.
If the value of identifier is anything other than a value within the range of 1 through n (where n is the number of procedure-names specified in this GO TO statement), no control transfer occurs. Instead, control passes to the next statement in the normal sequence of execution.
The altered GO TO statement transfers control to the first statement of the paragraph named in the ALTER statement.
You cannot specify the altered GO TO statement in the following:
An ALTER statement referring to the paragraph that contains the altered GO TO statement should be executed before the GO TO statement is executed. Otherwise, the GO TO statement acts like a CONTINUE statement.
Format 3: altered GO TO statement >>-paragraph-name--.--GO--+----+--.---------------------------->< '-TO-'
When an ALTER statement refers to a paragraph, the paragraph can consist only of the paragraph-name followed by an unconditional or altered GO TO statement.