cobol continuation character example

Cobol Continuation Character Example

By James Hernandez
AD

In the realm of programming, the need for brevity and efficiency often leads to the discovery of fascinating coding techniques. One such technique is the use of continuation characters in COBOL programming. These characters are essentially a way to extend the length of a line, allowing developers to write more complex code that is easier to read and maintain.

Continuation characters in COBOL are meant to improve code readability by permitting programmers to span a single logical thought across multiple physical lines. This approach not only enhances the code's aesthetics but also facilitates collaborative development, making it easier for other programmers to comprehend and contribute to the codebase.

Understanding Continuation Characters

In COBOL, continuation characters are typically represented by an asterisk (*) symbol. This character signals the COBOL compiler that the current logical line is not yet complete and that more code will follow on the subsequent physical line.

AD
Department of Computer Science and Information Systems
Department of Computer Science and Information Systems
a cartoon character sitting in front of a computer screen with a green alien on it
a cartoon character sitting in front of a computer screen with a green alien on it
the words cobol and common basic oriented language are shown in black on a white background
the words cobol and common basic oriented language are shown in black on a white background

Using continuation characters allows programmers to break up long, complex lines of code into smaller, more manageable chunks. This results in a cleaner, more organized code that can enhance the debugging, maintenance, and evolution processes.

Basic Syntax of Continuation Characters

The syntax of continuation characters in COBOL is relatively straightforward. To indicate a continuation, place an asterisk (*) in the first column. This tells the COBOL compiler not to treat the current line as a separate statement. The following line of code is then considered part of the same compound statement.

ICL COBOL Program Sheet...
ICL COBOL Program Sheet...
an image of a computer screen with the words'data division'in white letters
an image of a computer screen with the words'data division'in white letters
an old black and white photo with some type of data on it's side
an old black and white photo with some type of data on it's side

Consider the below COBOL continuation character example: ``` MOVE 'PROGRAM CONTINUATION' TO PROGRAM-NAME. IF CURRENT-DATE > EXPIRATION-DATE* PERFORM SUBROUTINE/E ``` In this example, the asterisk (*) on the first line indicates that the `IF` statement is not yet complete and that more code will follow immediately on the next line.

COBOL Continuation Characters and Program Structure

COBOL continuation characters are not merely a cosmetic tool. They play an essential role in preserving the structure and logic of a program. By using continuation characters, programmers can ensure that complex procedures, decision statements, and other structures are correctly nested and logically ordered.

AD

For instance, consider an intricate `PERFORM` statement that involves multiple conditional branches and iterations. Utilizing continuation characters can make it easier to comprehend and maintain the hierarchical structure of this code block.

the key cobol features are shown in different colors and shapes, including hexagonals
the key cobol features are shown in different colors and shapes, including hexagonals
COBOL Language: Call It A Comeback?
COBOL Language: Call It A Comeback?
an image of a tree diagram with numbers and symbols in the form of letters on it
an image of a tree diagram with numbers and symbols in the form of letters on it
a black background with red and green lines on it that are all over the place
a black background with red and green lines on it that are all over the place
COBOL EVALUATE statement — Syntax with Examples TutorialBrain
COBOL EVALUATE statement — Syntax with Examples TutorialBrain
an image of a computer code with numbers and symbols in the form of letters on it
an image of a computer code with numbers and symbols in the form of letters on it

Advanced Usage of Continuation Characters

While the basic usage of continuation characters is quite straightforward, there are more advanced techniques that can be employed to further enhance code readability and maintenance.

For example, continuation characters can be used strategically to create visually distinct code blocks. By using a common continuation character symbol throughout a procedure, it's easier for other programmers (and even the original author, during a future maintenance session) to quickly identify the boundaries and structure of the code.

AD

Continuation Characters and Comments

Continuation characters can also be used in combination with comment lines to create clear, logical separations within the code. Placing an asterisk (*) in the first column of a comment line can signal that the proceeding code block is coming to a close.

a black and white photo with numbers on it
a black and white photo with numbers on it
an image of a computer screen with text
an image of a computer screen with text
some type of typogramic poster with the words 2 mainframe cobol
some type of typogramic poster with the words 2 mainframe cobol
The Inevitable Return of COBOL - HackerRank Blog
The Inevitable Return of COBOL - HackerRank Blog
Files in Cobol - Mainframe COBOL Tutorial - Part 35 #COBOL
Files in Cobol - Mainframe COBOL Tutorial - Part 35 #COBOL
New Jersey needs volunteers who know COBOL, a 60-year-old programming language
New Jersey needs volunteers who know COBOL, a 60-year-old programming language
39 Facts About COBOL
39 Facts About COBOL
COBOL in 100 seconds
COBOL in 100 seconds
an advertisement for the cobral reference card, with instructions on how to use it
an advertisement for the cobral reference card, with instructions on how to use it
the uses of cool programming language for web design and application development, with text describing how it works
the uses of cool programming language for web design and application development, with text describing how it works
the ascii - binary character table is shown with numbers and letters on it
the ascii - binary character table is shown with numbers and letters on it
(9+) Instagram
(9+) Instagram
the asci library character table is shown with numbers and symbols on it's side
the asci library character table is shown with numbers and symbols on it's side
The Enduring Importance of COBOL in Financial Services
The Enduring Importance of COBOL in Financial Services

Consider the following example: ``` PROCEDURE DIVISION. PERFORM PROCEDURE-A. PERFORM PROCEDURE-B*.** ``` In this case, the double asterisk (**) on the comment line indicates that the preceding code block (consisting of `PROCEDURE-A` and `PROCEDURE-B`) is complete.

Continuation Characters with External Files

Another advanced use of continuation characters involves the `INCLUDE` statement. When dealing with external files using the `INCLUDE` statement, continuation characters can be used to concatenate lines in the included file.

AD

This technique can be invaluable when writing lines that exceed the 72-character COBOL limit, provided that the external file is written and maintained with care.

In conclusion, while COBOL continuation characters might initially seem like a simple stylistic tool, they offer a robust collection of features that contribute to better-structured, more readable, and maintainable code. Mastering their usage can significantly improve the programming experience and yield substantial benefits over the lifecycle of a COBOL project.

AD