ALTER Statement
The ALTER
Statement provides a mechanism for re-directing the destination of the GO TO
Statement.
General Format:
ALTER { proc-1 TO PROCEED TO proc-2 } …
Syntax:
proc-n
is the name of a procedure or section in the program.
General Rules:
- The
ALTER
statement indicates that whereproc-n
is indicated as the target of aGO TO
statement, the program should substitute an a different target proc. GO TO
statements targeting aproc-n
that has beenALTER
’ed are redirected to the proc named after thePROCEED TO
clause in theALTER
statement.
Code Sample:
IDENTIFICATION DIVISION.
PROGRAM-ID. ALTER-1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 ALTER-FLAG PIC 9 VALUE 1.
77 DUMMY PIC X.
PROCEDURE DIVISION.
MAIN.
DISPLAY "IF ALTER-FLAG..." LINE 2 COL 10.
IF ALTER-FLAG = 1
DISPLAY "ALTER ALTER-1-EXIT.... " LINE 3 COL 10
ALTER ALTER-1-EXIT TO PROCEED TO ALTER-2-EXIT
END-IF.
DISPLAY "GO TO ALTER-1-EXIT...." LINE 4 COL 10.
GOTO ALTER-1-EXIT.
ALTER-1-EXIT.
GOTO LABEL-1.
LABEL-1.
DISPLAY "ALTER-1 EXIT!" LINE 10 COL 10.
ACCEPT DUMMY LINE 10 COL 30.
STOP RUN.
ALTER-2-EXIT.
DISPLAY "ALTER-2 EXIT!" LINE 10 COL 10.
ACCEPT DUMMY LINE 10 COL 30.
STOP RUN.