Skip to content

ENTRY Statement

The ENTRY statement is used to establish an alternate entry point in the program.

General Format:

       ENTRY entry-name [ USING    { BY REFERENCE }     {data-1} ... ] 
                                   { BY VALUE     } 
                                   { BY CONTENT   }

Syntax:

  1. entry-name is a literal.
  2. Name resolution for ENTRY routines is case-sensitive.
  3. data-n is a data item.

General Rules:

  1. ENTRY statements cannot be used in nested subprograms.
  2. The program containing the ENTRY statement must be loaded in memory, when CALL’ed.
  3. The General Rules governing the USING clause, and passing of parameters is the same as the rules described in the Procedure Division Clause section.

Code Sample:

Note

Compile the two programs below with -b, e.g.

cobc -b entry-test.cbl entry-1.cbl
cobcrun entry-test

      * 
       IDENTIFICATION DIVISION. 
       PROGRAM-ID. ENTRY-TEST. 
       ENVIRONMENT DIVISION. 
       DATA DIVISION. 
       WORKING-STORAGE SECTION. 
       77 FLD-1 PIC X(10) VALUE "CALIFORNIA". 
       77 DUMMY PIC X. 
       PROCEDURE DIVISION. 
       MAIN. 
              DISPLAY "ENTRY-TEST BEGUN!" LINE 5 COL 10. 
              ACCEPT DUMMY LINE 10 COL 30. 
              CALL "DISP-STATE" USING FLD-1. 
              DISPLAY "ENTRY-TEST FINISHED!" LINE 15 COL 10. 
              ACCEPT DUMMY LINE 15 COL 30. 
              STOP RUN. 
      * 
       IDENTIFICATION DIVISION. 
       PROGRAM-ID. ENTRY-1. 
       ENVIRONMENT DIVISION. 
       DATA DIVISION. 
       WORKING-STORAGE SECTION. 
       77 DUMMY PIC X. 
       LINKAGE SECTION. 
       01 FIELD-1 PIC X(10). 
       PROCEDURE DIVISION. 
       MAIN. 
              DISPLAY "SUBPGM-1 FINISHED!" LINE 10 COL 10. 
              ACCEPT DUMMY LINE 10 COL 30. 
              STOP RUN. 

       ENTRY "DISP-STATE" USING FIELD-1. 
              DISPLAY FIELD-1 LINE 10 COL 10. 
              DISPLAY "ENTRY-1 FINISHED!" LINE 11 COL 10. 
              ACCEPT DUMMY LINE 11 COL 30. 
              EXIT PROGRAM.
Back to top