Reference Format [ Micro Focus COBOL Language Reference ] MPE/iX 5.0 Documentation
Micro Focus COBOL Language Reference
Reference Format
The whole of this section refers to fixed format only. Your COBOL system
also accepts programs written in free format. See the chapter
Introduction to the COBOL Language for details of source format.
The reference format, which provides a standard method for describing
COBOL source programs, is described in terms of character positions in a
line on an input-output medium. Your COBOL system accepts source
programs written in reference format and produces an output listing of
the source program coded using reference format. (See the chapter
Introduction for a sample source program.)
The rules for spacing given in the discussion of the reference format
take precedence over all other rules for spacing.
The divisions of a source program must be ordered as follows; the
Identification Division, then the Environment Division, then the Data
Division, then the Procedure Division. Each division must be written
according to the rules for the reference format.
For MF and XOPEN only: See also the section Free Format in the chapter
Introduction to the COBOL Language.
Reference Format Representation
The reference format for a line is represented as in Figure 3-1.
Figure 3-1: Reference Format for a COBOL Source Line
Margin L is immediately to the left of the leftmost character
position of a line.
Margin C is between the 6th and 7th character positions of a line.
Margin A is between the 7th and 8th character positions of a line.
Margin B is between the 11th and 12th character positions of a
line.
Margin R is immediately to the right of the 72nd character
position of a line.
For MF only: A line can extend up to the 80th character
position, but any characters occupying positions 73 to 80 are
ignored by your COBOL system.
The sequence number area occupies six character positions (1-6), and is
between Margin L and Margin C.
The indicatorarea is the 7th character position of a line.
Area Aoccupies character positions 8, 9, 10 and 11, and is between margin
A and margin B.
Area Boccupies character positions 12 through 72 inclusive; it begins
immediately to the right of Margin B and terminates immediately to the
left of Margin R.
Sequence Numbers.
A sequence number, normally consisting of six digits, can be placed in
the sequence area and can be used to label a source program line. This
sequence number is usually in ascending numeric order on each successive
source statement line of the program.
For VSC2 and OSVS only: This sequence number is the one used by the
BASIS mechanism (see the chapter Compiler-Directing Statements) for
line-editing, in which case it must be both numeric and in ascending
order through the program.
The ascending order of sequence numbers can be optionally verified by
your COBOL system. Refer to your COBOL System Reference for details of
the SEQCHK directivethat enables this.
For ANS85 only: There is no requirement for the content of this area to
be numeric, or even unique.
For MF only: If the first character position of the sequence number
field contains an asterisk, or any non-printing control character (less
than the character SPACE in the ASCII collating sequence), then the line
is treated as comment, and is not output to the listing file or device.
This facility allows an output listing fileto be used as a source file to
a subsequent compile. This support is sensitive to the MFCOMMENT system
directive. See your COBOL System Reference for details.
Continuation of Lines.
Whenever a sentence, entry, phrase, or clause requires more than one
line, it can be continued by starting subsequent line(s) in area B. These
subsequent lines are called the continuation line(s). Any word, literal
or PICTURE character-string(ANS85) can be broken in such a way that part
of it appears on a continuation line.
A hyphen in the indicator area of a line indicates that the first
nonblank character in area B of the current line is the successor of the
last nonblank character of the preceding line excluding intervening
comment or blank lines (ANS85) without any intervening space. However,
if the continued line contains a nonnumeric literal without closing
quotation mark, the first nonblank character in area B on the
continuation line must be a quotation mark, and the continuation starts
with the character immediately after that quotation mark. All spaces at
the end of the continued line are considered part of the literal. Area A
of a continuation line must be blank.
If there is no hyphen in the indicator area of a line, it is assumed that
the last character in the preceding line is followed by a space. Both
characters composing the separator "==" must be on the same line.
For VSC2 only: Characters "X" must be on the same line.
For MF only: Characters "H" must be on the same line.
Blank Lines.
A blank line is one that is blank from margin C to margin R, inclusive.
A blank line can appear anywhere in the source program.
Pseudo-text.
The text words and the separator space comprising pseudo-text can start
in either area A or area B. If, however, there is a hyphen in the
indicator area of a line which follows the opening pseudo-text delimiter,
area A of the line must be blank; and the normal rules for continuation
of lines apply to the formation of text words. (See the chapter
Compiler-Directing Statements.)
Division, Section and Paragraph Formats
Division Header.
The division header must start in area A. (See Figure 3-1.)
Section Header.
The section header must start in area A. (See Figure 3-1.)
A section consists of zero, one, or more paragraphs in the Environment
Division or Procedure Division or zero, one or more entries in the Data
Division.
Paragraph Header, Paragraph-name and Paragraph.
A paragraph consists of a paragraph-name followed by a period and a
space, and by zero, one or more sentences, or a paragraph header followed
by one or more entries. Comment entries can be included within a
paragraph. The paragraph header or paragraph-name starts in area A of
any line following the first line of a division or a section.
The first sentence or entry in a paragraph begins either on the same line
as the paragraph header or paragraph-name, or in area B of the next
nonblank line that is not a comment line. Successive sentences or
entries begin either in area B of the same line as the preceding sentence
or entry, or in area B of the next nonblank line that is not a comment
line.
For MF only: Sentences can begin anywhere in area A or area B unless
the AREACHECK directive is specified. See your COBOL System Reference
for details.
When the sentences or entries of a paragraph require more than one line,
they can be continued as described in the section Continuation Of Lines
earlier in this chapter.
Data Division Entries
Each Data Division entry begins with a level indicator or a level-number,
followed by a space, followed by its associated name if any (ANS85)
followed by a sequence of independent descriptive clauses. The last
clause is always terminated by a period followed by a space.
There are two types of Data Division entry; those which begin with a
level indicator and those which begin with a level-number.
A level indicator is any of the following:
* FD (see the section File Description - Complete Entry Skeleton in
the chapter Program Definition),
* SD (see the section Sort-Merge File Description - Complete Entry
Skeleton in the chapter Program Definition),
* CD (see the section Communication Description -Complete Entry
Skeleton in the chapter Communication in your Language Reference -
Additional Topics),
* RD (see the section The Report Description Entry in the chapter
Report Writer in your Language Reference - Additional Topics).
In those Data Divisionentries that begin with a level indicator, the
level indicator begins in area A followed by a space and followed in area
B or area A (ANS85) with its associated name and appropriate descriptive
information.
Those Data Division entries that begin with level-numbers are called data
description entries.
A level-number has a value taken from the set of values 1 through 49, 66,
77 , 7 (MF) and 88. Level-numbers in the range 1 through 9 can be
written either as a single digit or as a zero followed by a significant
digit. At least one space must separate a level-number from the word
following the level-number.
In those data description entries that begin with level-number 01 or 66,
77 , 78 (MF) and 88, the level-number begins in area A followed by a
space and followed in area B or area A (ANS85) by its associated
record-name or item-name and appropriate descriptive information.
Successive data description entries can have the same format as the first
or can be indented according to level-number. Indentation does not
affect the magnitude of a level-number.
When level-numbers are to be indented, each new level-number can begin
any number of spaces to the right of margin A. The extent of indentation
to the right is determined only by the width of the physical medium.
For MF only: Data descriptions and level numbers other than 01, 66,
77, and 88 can also begin in area A.
Declaratives
The key word DECLARATIVES and the key words END DECLARATIVES that precede
and follow, respectively, the declaratives portion of the Procedure
Division must each appear on a line by themselves. Each must begin in
area A and be followed by a period and a space (see Figure 3-1).
Comment Lines
A comment lineis any line with an asterisk (*) in the continuation
indicator area of the line. A comment line can appear as any line in a
source program after the Identification Division header. Any combination
of characters from the computer's character set can be included in area A
and area B of that line (see Figure 3-1). The asterisk and the
characters in area A and area B will be produced on the listing but serve
as documentation only.
For MF, OSVS and VSC2 only: A comment line can appear before the
Identification Division header.
A second form of comment line represented as above but with a slant (/)
(instead of an asterisk) in the indicator area of the line causes page
ejection prior to printing the comment.
Successive comment lines are allowed.Continuation of comment lines is
permitted, except that each continuation line must contain an "*" in the
indicator area.
For MF only: In-line Comment.
An in-line comment begins with the two contiguous characters "*>"
preceded by a separator space, and ends with the last character position
of the line. It allows free-form commentary to appear on the same line
as character-strings and/or separators. An in-line comment can appear
anywhere a separator space can appear in a COBOL source program or in a
library text of a COBOL library. For the purpose of evaluating library
text, pseudo-text and source text, an in-line comment has the value of a
single space character. An in-line comment cannot be continued onto
another line
Reserved Words
A full list of reserved words is given in the appendix Reserved Words.
MPE/iX 5.0 Documentation