COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

text-line
is a line of source text. There is no limit on the number of such lines. No text line can begin
with “?SECTION.
Usage Considerations:
COLUMNS Directive
The library can contain at most one COLUMNS directive. The COLUMNS directive must
precede all SECTION directives and must appear alone in its compiler directive line.
Furthermore, the line’s question mark must always be in column 1 (even if the ANSI source
text format applies).
SECTION Directive
Each SECTION directive must appear alone in a compiler directive line and the line’s question
mark must always be in column 1 (even if the ANSI source text format applies). Each SECTION
directive demarcates an individual text unrelated to any other contents of the source library.
A SECTION directive cannot appear anywhere in the text of a COPY statement (between the
word COPY and its terminating period in the input stream) or a REPLACE statement (between
the word REPLACE and its terminating period in the input stream); however, the compiler
detects and reports its appearance within pseudo-text only if that pseudo-text is introduced
into the source as the result of expanding the COPY statement or by the editing effects of the
REPLACE statement.
During program compilation, the compiler identifies a section by locating the SECTION
directive whose text-name matches the text-name specified in the COPY statement. For
more information, see SECTION (page 566).
Copying Sections of Text
The compiler copies text starting at the line after the SECTION directive line and continues
until it recognizes another SECTION directive or reaches the end of the file.
No COPY Statements in COPY Library Sections
The COPY statement cannot be within a section of a COPY library.
Reference Format
The compiler assumes that the reference format of the library text is the same as that of the
line containing the COPY statement, unless you specify a different format in the SECTION
directive. (For information on Tandem format, see Reference Format for Source Program Lines
(page 44). For information on ANSI format, see Chapter 16: ANSI Reference Format
(page 702).)
If you specify a reference format in a SECTION directive, that format is active only during
execution of the COPY statement. After the compiler copies a section, it uses the reference
format previously active.
Compiler Directives in a COPY Library
Source text in a COPY library can contain compiler directives, which the compiler obeys when
it analyzes the copied text.
Compiler Builds a Directory of the COPY Library
The first time the compiler reads from a COPY library, it begins to build a directory for itself
that enables it to locate the individual sections. It reads through the library, building its directory,
until it finds the selected section. After copying it, it resumes normal compilation. For subsequent
COPY statements, it checks its directory. If the chosen section is in the directory, the compiler
can go right to it; otherwise, it resumes reading the library where it left off, and continues as
COPY Libraries 507