Continuation Line


A continuation line is a line that continues from the previous line that exceeds the 72-column length. We can use the continuation line when a statement doesn't fit on one line or split it across multiple lines for better readability.

The first line that splits into multiple lines is called the Continued Line, and the following lines are called the Continuation Lines. For example -

Continuation Line Code

If there is no hyphen (-) in column 7, the last character of the preceding line is assumed as the last character of the line. For example -

Continuation Line Code

Rules -

  • The pseudo-text delimiter separator (==), the floating comment indicator (*>), or the compiler directive indicator (>>) should not be separated and must be on the same line.
  • If the continued line contains an alphanumeric literal without a closing quotation mark, all spaces till the end of the line (through column 72) are part of the literal. The continuation line must contain a hyphen (-) in the 7th column, and the first nonblank character must be a quotation mark in Area-B.

    For example - Continuation Line Code Continuation Line Code Continuation Line Code
  • If the last character on the continued line of an alphanumeric literal is a quotation mark, the continuation line can start with a quotation mark in Area-B.

    For example - Continuation Line Code

Practical Example -


Scenario - Explaining multiple ways of using continution lines.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       IDENTIFICATION DIVISION.
       PROGRAM-ID. CONTLINE.
       AUTHOR. MTH.

       DATA DIVISION. 
       WORKING-STORAGE SECTION. 
       01 WS-CONT-LINE1 PIC X(160) VALUE "THIS PART IS CONTINUED LINE & 
      -    "THIS PART IS CONTINUTION LINE1............................. 
      -    "THIS PART IS CONTINUTION LINE2". 

       01 WS-CONT-LINE2 PIC X(120) VALUE "THIS IS CONTINUED LINE &
      -    " THIS PART IS CONTINUTION LINE1".

       01 WS-CONT-LINE3 PIC X(120) VALUE "THIS PART IS CONTINUED LINE &"
      -    ""THIS PART IS CONTINUTION LINE1".

       01 WS-CONT-LINE4 PIC X(120) VALUE "THIS IS CONTINUED LINE & ".
 
       PROCEDURE DIVISION.
           DISPLAY "DISPLAYING CONTINUTION LINE1: " WS-CONT-LINE1.
           DISPLAY "DISPLAYING CONTINUTION LINE2: " WS-CONT-LINE2.
           DISPLAY "DISPLAYING CONTINUTION LINE3: " WS-CONT-LINE3.
           DISPLAY "DISPLAYING CONTINUTION LINE4: " WS-CONT-LINE4.
 
           STOP RUN.

Output -

Constant program Output