Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

COBOL  Module 1 – Start here: COBOL today, its standards, compilers and source format

Reference format: columns, Areas A and B, free-form

Read fixed-form COBOL by its columns, from the sequence area and indicator to Areas A and B and column 72, then switch to free-form with -free or >>SOURCE.

  • Beginner
  • 15 minutes
  • Examples run with GnuCOBOL 3.2 and Python 3.14.8
  • By MySmartCoPilot
Free lesson, Pro answers: 15 minutes
Free: the whole lesson. With a pass: the model answers to its 2 interview questions.

What you will learn

  • Identify the sequence area, the indicator area, Area A, Area B and the columns after 72 in a fixed-form line
  • Use the indicator column for comments, continuation lines and debugging lines
  • Detect source text beyond column 72 before it silently changes a program
  • Switch between fixed-form and free-form source with compiler options and >>SOURCE directives

Before you start

What you’ll learn · Before you start

What you will learn

  • Identify the sequence area, the indicator area, Area A, Area B and the columns after 72 in a fixed-form line
  • Use the indicator column for comments, continuation lines and debugging lines
  • Detect source text beyond column 72 before it silently changes a program
  • Switch between fixed-form and free-form source with compiler options and >>SOURCE directives

Before you start

On this page

A COBOL line that ends with + 1000000 can compile as + 10000. When the last two zeros sit in columns 73 and 74, the compiler drops them without a word, and a card limit meant to be 1,250,000 comes out as 260,000. Fixed-form COBOL is read by its columns, and a few of them decide what each line means.

Below you will take a fixed-form line apart column by column, use column 7 for comments, continuations and debugging lines, catch text that has slipped past column 72, and switch to free-form source, where the columns no longer count.

A fixed-form line has five areas, and each has one job

The reference format: The rules for where text goes on a line of COBOL source. Fixed form reads columns 7 to 72 of each line; free-form reads the whole line. fixes where text may go on a line of COBOL. In fixed form, IBM’s Language Reference divides each line into the sequence number area: Columns 1 to 6 of a fixed-form line. They may hold a number or a label for the line, and the compiler skips them., columns 1 to 6, the indicator area: Column 7 of a fixed-form line: a space for code, * or / for a comment, - for a continuation line and D for a debugging line., column 7, Area A: Columns 8 to 11 of a fixed-form line, where division, section and paragraph names, FD entries and the level numbers 01 and 77 begin., columns 8 to 11, and Area B: Columns 12 to 72 of a fixed-form line, which hold statements, clauses and the rest of each entry., columns 12 to 72. The compiler reads nothing after column 72. Each area has its own job:

Columns Area What goes there
1 to 6 Sequence number area A number or label for the line, never program text
7 Indicator area A space for code, or one of *, /, - and D
8 to 11 Area A Division, section and paragraph names, FD entries, the levels 01 and 77
12 to 72 Area B Statements, clauses and the rest of each entry
73 to 80 After the program text Nothing, or a tag that the compiler skips

Older programs still use the outer areas. This one carries a line number in columns 1 to 6 and a program tag, LAYOUT01, in columns 73 to 80 of every line but the first, a comment that works as a ruler, with a digit at every tenth column:

layout.cob: numbers in 1 to 6, a tag in 73 to 80 COB · layout.cob
....+.*..1....+....2....+....3....+....4....+....5....+....6....+....7..
000100 IDENTIFICATION DIVISION.                                         LAYOUT01
000200 PROGRAM-ID. LAYOUT.                                              LAYOUT01
000300* Columns 1-6 hold card numbers, 73-80 a program tag.             LAYOUT01
000400 DATA DIVISION.                                                   LAYOUT01
000500 WORKING-STORAGE SECTION.                                         LAYOUT01
000600 01  ACCOUNT-ID       PIC X(6) VALUE "AC0001".                    LAYOUT01
000700 PROCEDURE DIVISION.                                              LAYOUT01
000800 SHOW-ACCOUNT.                                                    LAYOUT01
000900     DISPLAY "Account " ACCOUNT-ID                                LAYOUT01
001000     STOP RUN.                                                    LAYOUT01

The session prints both outer areas with cut, then builds the program, and builds a second one, misplaced.cob, with a statement that starts in Area A and a paragraph name in Area B:

What cobc does with each area Python · layout_session.py
from session import files, run

# A program in the old card layout, with numbers in columns 1-6 and a tag in 73-80, which cobc ignores; then a program
# with a statement in Area A and a paragraph name in Area B, which only the ibm dialect reports.
files("layout.cob", "misplaced.cob")
run("""
cut -c1-6 layout.cob | sed -n '2,4p'
cut -c73-80 layout.cob | sed -n '2,4p'
cobc -x layout.cob
./layout
cobc -x misplaced.cob && ./misplaced
cobc -x -std=ibm -o misplaced-ibm misplaced.cob
""")

Output

$ cut -c1-6 layout.cob | sed -n '2,4p'
000100
000200
000300
$ cut -c73-80 layout.cob | sed -n '2,4p'
LAYOUT01
LAYOUT01
LAYOUT01
$ cobc -x layout.cob
$ ./layout
Account AC0001
$ cobc -x misplaced.cob && ./misplaced
Two lines in the wrong area
$ cobc -x -std=ibm -o misplaced-ibm misplaced.cob
misplaced.cob:5: warning: 'MAIN-PARA' should start in Area A [-Wothers]
    3 |       * A statement that starts in Area A, and a paragraph name in B.
    4 |        PROCEDURE DIVISION.
    5 >            MAIN-PARA.
    6 |        DISPLAY "Two lines in the wrong area".
    7 |            STOP RUN.
misplaced.cob: in paragraph 'MAIN-PARA':
misplaced.cob:6: warning: start of statement in Area A [-Wothers]
    4 |        PROCEDURE DIVISION.
    5 |            MAIN-PARA.
    6 >        DISPLAY "Two lines in the wrong area".
    7 |            STOP RUN.
    8 | <EOF>

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 layout_session.py

layout.cob compiled and printed Account AC0001, so the line numbers and the tags changed nothing. Enterprise COBOL never reads the numbers as code either, but its SEQUENCE option, on by default, checks that they ascend and reports a line that is out of order. misplaced.cob compiled too: GnuCOBOL’s default dialect does not check the areas at all. Only -std=ibm, whose dialect file turns areacheck on, warned that MAIN-PARA should start in Area A and that a statement started in Area A. Follow one line through the compiler, area by area:

Interactive · stage by stage How cobc reads one fixed-form line, column by column Step down the column. The line is line 7 of layout.cob, and each stage is one area of it.
How cobc reads one fixed-form line, column by column, step 5 of 5. Showing Columns 1 to 6, Column 7, Columns 8 to 11, Columns 12 to 72, Columns 73 to 80. In focus: Columns 73 to 80.Columns 1 to 6sequence area: 000600Column 7indicator: a spaceColumns 8 to 11Area A: 01 begins hereColumns 12 to 72Area B: ACCOUNT-ID ...Columns 73 to 80past 72: LAYOUT01

The drawing shows the whole scene; its 5 steps are listed below.

Every step as text
  1. The sequence area. Columns 1 to 6 once held the number of a punched card, here 000600. GnuCOBOL skips them, so they may hold anything or nothing.
  2. The indicator. Column 7 says what kind of line this is. A space means an ordinary line of code; an asterisk would make it a comment and a hyphen a continuation.
  3. Area A. Columns 8 to 11 are Area A, where division, section and paragraph names, FD entries and the level numbers 01 and 77 begin. The 01 of ACCOUNT-ID starts in column 8.
  4. Area B. Columns 12 to 72 are Area B, for the rest of the entry and for statements. The data name, its PICTURE and its VALUE clause all fit before column 73.
  5. Past the margin. Everything after column 72 is outside the program text, and cobc ignores it without a word. That made room for a program tag, LAYOUT01 here, and it is also where a cut-off word or number disappears.

Trusting the default dialect to check the areas

Wrong: taking a clean build on your laptop as proof that every name and statement is in its area. Right: build code that will run on z/OS with -std=ibm, which reports a paragraph name outside Area A and a statement inside it.

Column 7 decides what kind of line it is

The indicator area holds one character, and IBM’s documentation gives each one a meaning. A space makes an ordinary line of code. An asterisk makes a comment line; a slash also makes a comment, and starts a new page of the compiler listing. A hyphen makes a continuation line: A fixed-form line with - in column 7 that carries on a word or literal from the line before. A continued literal keeps every blank up to column 72., which carries on a word or literal from the line before. A D makes a debugging line: A fixed-form line with D in column 7. It is compiled only when debugging lines are switched on, by WITH DEBUGGING MODE or cobc -fdebugging-line, and is a comment otherwise., which is compiled only when debugging lines are switched on. This program uses all four:

indicators.cob: every use of column 7 COB · indicators.cob
....+.*..1....+....2....+....3....+....4....+....5....+....6....+....7..
       IDENTIFICATION DIVISION.
       PROGRAM-ID. INDICATORS.
      * An asterisk in column 7 makes this line a comment.
      / A slash is a comment too, and starts a new listing page.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-MESSAGE   PIC X(70).
       PROCEDURE DIVISION.
           MOVE "Payment received, thank you for banking
      -        "with us." TO WS-MESSAGE
           DISPLAY "[" FUNCTION TRIM(WS-MESSAGE TRAILING) "]"
      D    DISPLAY "Debugging line: this ran"
           STOP RUN.

Line 10 opens a literal and stops in column 56 without closing it. Line 11 has a hyphen in column 7 and carries on the literal after its quote. Build the program twice, the second time with GnuCOBOL’s -fdebugging-line:

Comments, a continued literal and a debugging line Python · indicators_session.py
from session import files, run

# Column 7 at work: two kinds of comment, a continued literal and a debugging line, compiled without and with debugging lines.
files("indicators.cob")
run("""
cobc -x indicators.cob
./indicators
cobc -x -fdebugging-line -o indicators-debug indicators.cob
./indicators-debug
""")

Output

$ cobc -x indicators.cob
$ ./indicators
[Payment received, thank you for banking                with us.]
$ cobc -x -fdebugging-line -o indicators-debug indicators.cob
$ ./indicators-debug
[Payment received, thank you for banking                with us.]
Debugging line: this ran

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 indicators_session.py

The comments did nothing, as comments should. The message has a long gap: an open literal runs to column 72, blanks included, so columns 57 to 72, 72 − 56 = 16 spaces, became part of it before with us. was added. The debugging line ran only in the second build. Writing WITH DEBUGGING MODE in the SOURCE-COMPUTER paragraph switches debugging lines on from inside the program, as IBM’s documentation describes it; the GnuCOBOL option does the same from outside and leaves the source untouched.

Avoid the gap in a continued literal

Either fill the first part of the literal up to column 72, or do not continue it at all: write two shorter literals and join them with &, as the free-form example below does.

Checkpoint

Check: The five areas of a fixed-form line · The indicator column

  1. Question 1 of 2 In a fixed-form line, which of these must begin in Area A, columns 8 to 11?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: The paragraph name SHOW-ACCOUNT.

    Area A holds the names that structure the program and the 01 and 77 levels; everything inside them, statements and clauses, starts in Area B. IBM's Language Reference lists the items that must begin in Area A.

  2. Question 2 of 2 Line 10 of indicators.cob ends in column 56, inside an open literal, and line 11 continues it. How many spaces were added between banking and with?

    Type a number.

    A hint

    The literal runs to the end of the program text, column 72.

    Show the answer: Question 2 of 2

    Answer: 16 spaces

    An open literal runs to column 72, blanks included, so columns 57 to 72, 72 − 56 = 16 of them, became part of the value. The continuation line then resumed after its opening quote, with with us., which is why the output shows a long gap.

Text after column 72 disappears without an error

Here is the program from the opening. Line 9 used to fit inside column 72; then the base limit was renamed to a longer name, and the last two zeros of 1000000 slid into columns 73 and 74:

cardlimit.cob: a literal that crosses column 72 COB · cardlimit.cob
       IDENTIFICATION DIVISION.
       PROGRAM-ID. CARDLIM.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-RETAIL-CUSTOMER-BASE-LIMIT PIC 9(7) VALUE 250000.
       01  WS-CARD-LIMIT                 PIC 9(7).
       PROCEDURE DIVISION.
      * The card limit is the base limit plus 1000000.
           COMPUTE WS-CARD-LIMIT = WS-RETAIL-CUSTOMER-BASE-LIMIT + 1000000
           DISPLAY "WS-CARD-LIMIT = " WS-CARD-LIMIT
           STOP RUN.

Build it plainly, with the warnings you would try first, with two warnings together and with -Wextra, and then look at the file itself with a one-line awk check that prints whatever lies after column 72:

Two lost zeros, and the checks that find them Python · column72_session.py
from session import files, run

# Two zeros past column 72: the program that loses them, the warnings that see them, and a check that shows them.
files("cardlimit.cob", "layout.cob")
run("""
cobc -x cardlimit.cob
./cardlimit
cobc -x -Wall -Wdangling-text -o cardlimit-wall cardlimit.cob
cobc -x -Wdangling-text -Wcolumn-overflow -o cardlimit-both cardlimit.cob
cobc -x -Wextra -o cardlimit-extra cardlimit.cob 2>&1 | sed -n '1p'
awk 'length > 72 { print FILENAME ":" FNR ": " substr($0, 73) }' cardlimit.cob
cobc -x -Wdangling-text -Wcolumn-overflow -o layout-both layout.cob 2>&1 | grep -c 'after program-text area'
awk 'length > 72 { print FILENAME ":" FNR ": " substr($0, 73) }' layout.cob | sed -n '1,3p'
""")

Output

$ cobc -x cardlimit.cob
$ ./cardlimit
WS-CARD-LIMIT = 0260000
$ cobc -x -Wall -Wdangling-text -o cardlimit-wall cardlimit.cob
$ cobc -x -Wdangling-text -Wcolumn-overflow -o cardlimit-both cardlimit.cob
cardlimit.cob:9: warning: source text after program-text area (column 72) [-Wdangling-text]
    7 |        PROCEDURE DIVISION.
    8 |       * The card limit is the base limit plus 1000000.
    9 >            COMPUTE WS-CARD-LIMIT = WS-RETAIL-CUSTOMER-BASE-LIMIT + 100000..
   10 |            DISPLAY "WS-CARD-LIMIT = " WS-CARD-LIMIT
   11 |            STOP RUN.
$ cobc -x -Wextra -o cardlimit-extra cardlimit.cob 2>&1 | sed -n '1p'
cardlimit.cob:9: warning: source text after program-text area (column 72) [-Wdangling-text]
$ awk 'length > 72 { print FILENAME ":" FNR ": " substr($0, 73) }' cardlimit.cob
cardlimit.cob:9: 00
$ cobc -x -Wdangling-text -Wcolumn-overflow -o layout-both layout.cob 2>&1 | grep -c 'after program-text area'
9
$ awk 'length > 72 { print FILENAME ":" FNR ": " substr($0, 73) }' layout.cob | sed -n '1,3p'
layout.cob:2: LAYOUT01
layout.cob:3: LAYOUT01
layout.cob:4: LAYOUT01

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 column72_session.py

The plain build printed WS-CARD-LIMIT = 0260000: 250,000 plus 10,000, not plus 1,000,000. -Wall with -Wdangling-text stayed silent. Only -Wdangling-text and -Wcolumn-overflow together, on GnuCOBOL 3.2, warned that line 9 has source text after the program-text area, and so did -Wextra, which turns on more warnings than -Wall. The awk check needs no compiler and shows the text itself: cardlimit.cob:9: 00. On layout.cob the same two warnings fired 9 times, once for every tagged line of code, because a tag is text after column 72 too; there the awk listing tells tags and lost digits apart at a glance. Step through what happened to line 9:

Interactive · stage by stage Where the two zeros of 1000000 went Step down the column, from the line as typed to the number the program printed.
Where the two zeros of 1000000 went, step 4 of 4. Showing The line as typed, Cut after column 72, The statement compiled, The result. In focus: The result.The line as typed74 characters longCut after column 72zeros in 73-74 droppedThe statement compiled... + 10000The result0260000, not 1250000

The drawing shows the whole scene; its 4 steps are listed below.

Every step as text
  1. As typed. Line 9 is 74 characters long. The literal 1000000 starts in column 68, so its last two zeros fall in columns 73 and 74. Renaming the base limit to a longer name is what pushed them there.
  2. The cut. In fixed form the program text ends at column 72, so cobc keeps columns 1 to 72 and drops the rest, here the two zeros.
  3. Still valid COBOL. What is left, COMPUTE WS-CARD-LIMIT = WS-RETAIL-CUSTOMER-BASE-LIMIT + 10000, is a correct statement, so nothing fails to compile and -Wall stays silent.
  4. A wrong limit. 250000 plus 10000 gave 260000, printed as 0260000, where the comment promised 250000 plus one million, 1250000.

Key idea

In fixed form the program text ends at column 72, silently, so check every line for text past it: with -Wdangling-text -Wcolumn-overflow, or with the awk listing when lines carry tags.

Free-form source drops the columns

Free-form source has no sequence area, no indicator column and no margin at 72: the GnuCOBOL manual says its program text starts in column 1 and runs to the end of the line, up to 255 characters. Comments start with *>, anywhere on a line. Here is the card-limit program again, in free-form, with line 9 at 92 characters:

freeform.cob: the same calculation, no columns COB · freeform.cob
*> Free-form source: no sequence area, no indicator column, no column 72.
IDENTIFICATION DIVISION.
PROGRAM-ID. FREEFORM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-RETAIL-CUSTOMER-BASE-LIMIT PIC 9(7) VALUE 250000.
01 WS-CARD-LIMIT                 PIC 9(7).
PROCEDURE DIVISION.
    COMPUTE WS-CARD-LIMIT = WS-RETAIL-CUSTOMER-BASE-LIMIT + 1000000 *> the whole line counts
    DISPLAY "WS-CARD-LIMIT = " WS-CARD-LIMIT
    STOP RUN.

GnuCOBOL 3.2 decides the format by itself when you do not name one: its NEWS says it reads column 7 of the first line that is not blank. You can also name it, with -free or --fixed, or switch inside a file with the directive >>SOURCE FORMAT IS FREE. The session tries each, and the last build joins two short literals with &:

Free-form detected, chosen and switched on Python · freeform_session.py
from session import files, run

# Free-form source: detected by cobc, chosen with -free, switched on inside a file with >>SOURCE FORMAT IS FREE, and a
# long literal built from two joined with &.
files("freeform.cob", "directive.cob", "joinlit.cob")
run("""
cobc -x freeform.cob
./freeform
cobc -x --fixed -o freeform-fixed freeform.cob 2>&1 | sed -n '1p'
cobc -x -free -o freeform-flag freeform.cob && ./freeform-flag
cobc -x --fixed directive.cob && ./directive
sed 's/^       >>SOURCE/>>SOURCE/' directive.cob > directive-col1.cob
cobc -x --fixed -o directive-col1 directive-col1.cob 2>&1 | sed -n '1p'
cobc -x -free joinlit.cob && ./joinlit
""")

Output

$ cobc -x freeform.cob
freeform.cob:1: note: free format detected
    1 > *> Free-form source: no sequence area, no indicator column, no column 72.
    2 | IDENTIFICATION DIVISION.
    3 | PROGRAM-ID. FREEFORM.
$ ./freeform
WS-CARD-LIMIT = 1250000
$ cobc -x --fixed -o freeform-fixed freeform.cob 2>&1 | sed -n '1p'
freeform.cob:1: error: invalid indicator 'e' at column 7
$ cobc -x -free -o freeform-flag freeform.cob && ./freeform-flag
WS-CARD-LIMIT = 1250000
$ cobc -x --fixed directive.cob && ./directive
Free-form from line 3 on
$ sed 's/^       >>SOURCE/>>SOURCE/' directive.cob > directive-col1.cob
$ cobc -x --fixed -o directive-col1 directive-col1.cob 2>&1 | sed -n '1p'
directive-col1.cob:2: error: invalid indicator 'C' at column 7
$ cobc -x -free joinlit.cob && ./joinlit
[Payment received, thank you for banking with us.]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 freeform_session.py

freeform.cob printed 1250000, the right limit, because nothing was cut. --fixed read its first line by the old columns and stopped at the e in column 7, which is not an indicator. directive.cob starts in fixed form and switches with the directive written from column 8; the copy with the directive in column 1 failed, because under --fixed cobc read that line by the columns too and found C, from SOURCE, in column 7. The dialects ibm and cobol2014 read fixed form by default, so the same rule applies under them. Side by side, the two formats differ in four ways:

Feature Fixed form Free-form
Program text Columns 8 to 72 The whole line, up to 255 characters
Comments * or / in column 7, or *> *>
Line numbers and tags Columns 1 to 6 and 73 to 80 None: they would be read as code
Chosen with --fixed, or by detection -free, >>SOURCE FORMAT IS FREE, or by detection

Name the format for old sources

Pass --fixed when you build legacy fixed-form code, and -free for free-form files, so that a file with an unusual first line is never guessed wrong.

Checkpoint

Check: Text after column 72 · Free-form source and >>SOURCE

  1. Question 1 of 2 Which build of cardlimit.cob printed a warning about the text after column 72?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: The build with -Wdangling-text and -Wcolumn-overflow together

    On GnuCOBOL 3.2 the warning needed both -Wdangling-text and -Wcolumn-overflow, or -Wextra, which printed the same warning in the session. -Wall, even with -Wdangling-text, stayed silent.

  2. Question 2 of 2 In a file compiled with --fixed, where does >>SOURCE FORMAT IS FREE have to start to be read as a directive?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: In column 8 or later

    A directive is read under the current format. Under --fixed, and under fixed-form dialects such as ibm and cobol2014, write it from column 8 on; once read, the rest of the file is free-form.

Practise: columns, indicators and formats

Use the example files and their runs to answer. Practice starts with your weakest concept and explains every choice as soon as you check it:

Practice that adapts to you

Practise this lesson

11 questions about 4 ideas of this lesson. Each answer is explained at once, and what you get right is kept in this browser.

  1. Question 1 of 11 Which parts of a fixed-form line does cobc ignore?

    Choose every answer that is right.

    Show the answer: Question 1 of 11

    Answer:

    • Columns 73 to 80
    • Columns 1 to 6, the sequence number area

    Of the 80 columns of a card, cobc reads 7 to 72: the indicator and the two areas of program text. Columns 1 to 6 and 73 to 80 are for people and their tools.

  2. Question 2 of 11 You receive a legacy program with card numbers in columns 1 to 6 and a tag in columns 73 to 80 on every line. What must you do before compiling it?

    Choose one answer.

    Show the answer: Question 2 of 11

    Answer: Nothing for those areas, but check that no code reaches past column 72

    Card numbers and tags are harmless in fixed form. What deserves a check is the margin: an awk check for text after column 72 lists every tag, and any line where something else is there.

  3. Question 3 of 11 What does a hyphen in column 7 mean?

    Choose one answer.

    Show the answer: Question 3 of 11

    Answer: The line continues a word or literal from the line before

    Column 7 holds a space for ordinary code, * or / for a comment (the slash also starts a new listing page), - for a continuation and D for a debugging line.

  4. Question 4 of 11 indicators.cob was first built without -fdebugging-line. What did its D line do in that build?

    Choose one answer.

    Show the answer: Question 4 of 11

    Answer: Nothing, it was treated as a comment

    A debugging line is compiled only when debugging lines are switched on, with -fdebugging-line in GnuCOBOL or WITH DEBUGGING MODE in the program; otherwise it is a comment.

  5. Question 5 of 11 A continued literal shows an unwanted gap of spaces in the middle of a message. How do you remove the gap?

    Choose one answer.

    Show the answer: Question 5 of 11

    Answer: Fill the first part of the literal up to column 72, or split it into two literals that each fit on their line

    A fixed-form literal continues from column 72 of one line to the first character after the quote on the next. Text that ends earlier leaves blanks in the value, 16 of them in indicators.cob.

  6. Question 6 of 11 What did the awk check print for cardlimit.cob?

    Choose one answer.

    Show the answer: Question 6 of 11

    Answer: cardlimit.cob:9: 00

    awk 'length > 72 { … substr($0, 73) }' prints the file name, the line number and the text after column 72, which is exactly what the compiler drops.

  7. Question 7 of 11 Suppose line 9 had ended with + 2000000 instead of + 1000000, again with its last two digits past column 72. What would WS-CARD-LIMIT hold?

    Type a number.

    A hint

    Cut the literal after its fifth digit, then add the base limit.

    Show the answer: Question 7 of 11

    Answer: 270000

    The compiler would keep 20000 and drop 00, so the limit would be 250000 + 20000 = 270000, printed as 0270000, instead of 2250000.

  8. Question 8 of 11 The two warning flags printed 9 warnings for layout.cob. Why, and what do you use there instead?

    Choose one answer.

    Show the answer: Question 8 of 11

    Answer: Every tagged line has text after column 72, so use the awk check to see what is there and tell tags from code

    On a source whose lines carry tags, the warning fires on every line and buries a real problem. List what is past column 72 instead, or strip the tags with cut -c1-72 and then use the warnings.

  9. Question 9 of 11 Which characters start a comment in free-form source?

    Choose one answer.

    Show the answer: Question 9 of 11

    Answer: *>

    In free-form source *> starts a comment that runs to the end of the line, at the start of a line or after code.

  10. Question 10 of 11 How did cobc decide, without -free, that freeform.cob was free-form?

    Choose one answer.

    Show the answer: Question 10 of 11

    Answer: From column 7 of its first non-blank line, which held e, not a valid indicator

    GnuCOBOL 3.2's NEWS describes the detection: it reads column 7 of the first non-blank line. Pass -free or --fixed when a file could be guessed wrongly.

  11. Question 11 of 11 A team converts a fixed-form program to free-form by deleting the first 6 columns of every line. What else must they change?

    Choose every answer that is right.

    Show the answer: Question 11 of 11

    Answer:

    • The lines that use column 7, comments, continuations and D lines, which free-form does not read that way
    • Any text after column 72, such as tags, which free-form reads as program text

    Fixed form gives meaning to column 7 and ignores 73 to 80; free-form does neither. A conversion has to rewrite the indicator lines as *> comments or joined literals, and remove the tags.

Measure your own sources

Run awk 'length > 72 { print FILENAME ":" FNR ": " substr($0, 73) }' *.cob in a folder of fixed-form programs. Every line it prints is either a tag or code the compiler never sees; look at each one.

Interview questions

Warm-up (fresher to 2–5 years): which areas make up a fixed-form COBOL line, and what goes in each?

A fixed-form line has five parts. Columns 1 to 6 are the sequence number area, once used to number the lines, which the compiler never reads as program text. Column 7 is the indicator area: a space for code, * or / for a comment, - for a continuation line and D for a debugging line. Columns 8 to 11 are Area A, where division, section and paragraph names, FD entries and the levels 01 and 77 begin. Columns 12 to 72 are Area B, for statements, clauses and the rest of each entry. Everything after column 72 is ignored, which leaves room for a tag in columns 73 to 80 and also means that code which runs past column 72 is cut off without an error: a literal 1000000 crossing the margin compiled as 10000.

Two harder questions follow, about a limit that shrank after a rename and about converting a code base to free-form. Note your own answer first, then open each first step:

Model answers open with any pass: ₹79 for 1 week ($2.99), one payment that never renews.

  1. Mid to senior

    After a teammate renamed a data item, a credit-limit calculation began giving smaller limits, yet the program compiles without warnings and the changed lines look correct. What do you suspect, how do you prove it, and how do you stop it happening again?

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  2. Senior to staff

    Your team wants to move its fixed-form COBOL to free-form source. What would you check before and after converting, and what might make you keep fixed form?

    Model answer, Pro. First step and follow-ups

Organisations named on this page

IBM and the GnuCOBOL project are named here only as the sources of the column rules quoted, from their public documentation under References; MySmartCoPilot has no link with either.

Flashcards · 8 cards

Recall it, then check

Say the answer to yourself before you look: recalling it is what makes it stick.

  1. What are the five areas of a fixed-form COBOL line?

    Columns 1 to 6: sequence numbers. Column 7: the indicator. Columns 8 to 11: Area A. Columns 12 to 72: Area B. The compiler reads nothing after column 72, so 73 to 80 can hold a tag.

  2. What starts in Area A, and what goes in Area B?

    Area A, columns 8 to 11, holds division, section and paragraph names, FD entries and the levels 01 and 77. Area B, columns 12 to 72, holds statements, clauses and the rest of each entry.

  3. What do the characters *, /, - and D mean in column 7?

    * makes a comment line, and / a comment that also starts a new listing page. - makes a continuation line. D makes a debugging line, which the compiler treats as a comment unless debugging lines are switched on.

  4. Why did a literal continued onto the next line contain a long run of spaces?

    An unclosed literal runs to column 72, blanks included, so every space after its last character became part of it. Fill the first part to column 72, or join two literals with &.

  5. A literal 1000000 compiled as 10000. What happened, and what finds it?

    Its last two zeros sat in columns 73 and 74, which cobc ignores without an error. -Wdangling-text with -Wcolumn-overflow, -Wextra, or an awk listing of the text after column 72 shows it.

  6. Does GnuCOBOL's default dialect warn about a paragraph name in Area B?

    No, it does not check the areas at all. -std=ibm turns on areacheck and warns about a paragraph name outside Area A and a statement inside it.

  7. How does free-form source differ from fixed form?

    Its text runs from column 1 to the end of the line, up to 255 characters, with comments written as *> anywhere. Choose it with -free, with >>SOURCE FORMAT IS FREE, or let cobc detect it.

  8. How does GnuCOBOL 3.2 decide whether a file holds fixed-form or free-form source?

    It reads column 7 of the first line that is not blank. Pass --fixed or -free for old sources, so that a file with an unusual first line is never guessed wrong.

Key takeaways

  • A fixed-form line has a sequence number area in columns 1 to 6, the indicator in column 7, Area A in 8 to 11 and Area B in 12 to 72, and the compiler ignores everything after column 72.
  • Column 7 holds * or / for a comment, - for a continuation line and D for a debugging line, and a continued literal keeps every blank up to column 72, 16 spaces in indicators.cob.
  • Text after column 72 is dropped without an error, which turned 1000000 into 10000, and only -Wdangling-text with -Wcolumn-overflow, -Wextra or an awk listing shows it.
  • GnuCOBOL’s default dialect does not check Areas A and B, while -std=ibm warns about a paragraph name or a statement in the wrong area.
  • Free-form source uses the whole line and *> comments, and it is chosen by detection, with -free, or with >>SOURCE FORMAT IS FREE written where the current format reads it.

Terms in this lesson

Area A
Columns 8 to 11 of a fixed-form line, where division, section and paragraph names, FD entries and the level numbers 01 and 77 begin.
Area B
Columns 12 to 72 of a fixed-form line, which hold statements, clauses and the rest of each entry.
continuation line
A fixed-form line with - in column 7 that carries on a word or literal from the line before. A continued literal keeps every blank up to column 72.
debugging line
A fixed-form line with D in column 7. It is compiled only when debugging lines are switched on, by WITH DEBUGGING MODE or cobc -fdebugging-line, and is a comment otherwise.
indicator area
Column 7 of a fixed-form line: a space for code, * or / for a comment, - for a continuation line and D for a debugging line.
reference format
The rules for where text goes on a line of COBOL source. Fixed form reads columns 7 to 72 of each line; free-form reads the whole line.
sequence number area
Columns 1 to 6 of a fixed-form line. They may hold a number or a label for the line, and the compiler skips them.

References

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.