Reference Format [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation
COBOL/HP-UX Language Reference for the Series 700 and 800
Reference Format
General Description
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 Chapter 1
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.
Reference Format Representation
The reference format for a line is represented as in Figure 2-3 .
Figure 2-3. 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.
________________________________________________________________________
|(MF) |
|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 indicator area is the 7th character position of a line.
Area A occupies character positions 8, 9, 10 and 11, and is between
margin A and margin B.
Area B occupies 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.
________________________________________________________________________
|(VSC2) (OSVS) |
|This sequence number is the one used by the BASIS mechanism (see |
|Chapter 6 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 directive that enables this.
________________________________________________________________________
|(ANS85) |
|There is no requirement for the content of this area to be numeric, or|
|even unique. |
________________________________________________________________________
________________________________________________________________________
|(MF) |
|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 comments, and is not output to the listing file or device. |
|This facility allows an output listing file to 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.
________________________________________________________________________
|(VSC2) Characters "X" must be on the same line. |
________________________________________________________________________
________________________________________________________________________
|(MF) 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 Chapter 6
Compiler Directing Statements.)
Division, Section, Paragraph Formats
Division Header.
The division header must start in area A. (See Figure 2-3.)
Section Header.
The section header must start in area A. (See Figure 2-3.)
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.
________________________________________________________________________
|(MF) |
|Note: Sentences can begin anywhere in area A or area B. |
________________________________________________________________________
When the sentences or entries of a paragraph require more than one line,
they can be continued as described in Continuation Of Lines 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)
(except in the Report Section), followed by a sequence of independent
descriptive clauses. Each clause, except the last clause of an entry,
can be terminated by either the separator semicolon or the separator
comma. 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 File Description -
Complete Entry Skeleton in Chapter 5 File Input and Output), SD (see
Sort-Merge File Description - Complete Entry Skeleton in Chapter 5
File Input and Output), CD (see Communication Description -Complete Entry
Skeleton in the chapter Communication), or RD (see The Report Description
Entry in the chapter Report Writer).
In those Data Division entries 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 , 78 (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.
________________________________________________________________________
|(ANS85) |
|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 2-3 ).
Comment Lines
A comment line is 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 2-3). The asterisk and the
characters in area A and area B will be produced on the listing but serve
as documentation only.
________________________________________________________________________
|(MF) (OSVS) (VSC2) |
|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.
________________________________________________________________________
|(MF) |
|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. |
________________________________________________________________________
MPE/iX 5.0 Documentation