action.skip

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:

  1. The ALTER statement indicates that where proc-n is indicated as the target of a GO TO statement, the program should substitute an a different target proc.
  2. GO TO statements targeting a proc-n that has been ALTER’ed are redirected to the proc named after the PROCEED TO clause in the ALTER 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.