GO TO Statement COBOL

The GO TO statement causes control to be transferred from one part of the Procedure Division to another.

Format 1:Go To (Alterable)

GO TO [ procedure-name-1 ]

Format 2:Go To (Non-Alterable)

GO TO procedure-name-1

Format 3:Go To…Depending On

GO TO { procedure-name-1 }… DEPENDING ON identifier-1

A Format 1 GO TO statement can only appear in a single statement paragraph and can be altered with an ALTER statement.

When a paragraph is referenced by an ALTER statement, that paragraph can consist only of a paragraph header followed by a Format 1 GO TO statement.

If procedure-name-1 is not specified in Format 1, an ALTER statement, referring to the paragraph containing this GO TO statement, must be executed prior to the execution of this GO TO statement; otherwise, the run unit is terminated with an error message when the GO TO statement is executed.

When a Format 1 or 2 GO TO statement is executed, control is transferred to procedure-name-1 or to another procedure-name if the GO TO statement has been modified by an ALTER statement.

If a Format 2 GO TO statement appears in a consecutive sequence of imperative statements within a sentence, it must appear as the last statement in that sequence.

DEPENDING ON Phrase

DEPENDING ON identifier-1

When a Format 3 GO TO statement is executed, control is transferred to procedure-name-1 depending on the value of identifier-1 being 1, 2, . . ., n. If the value of identifier-1 is anything other than the positive or unsigned integers 1, 2, . . ., n, no transfer occurs and control passes to the next statement in the normal sequence for execution.

identifier-1 must refer to a numeric integer elementary data item.

GO TO Statement Example



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

COBOL Topics