COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
The text from the section summoned by the SOURCE directive is listed, subject only to the LIST
and SUPPRESS directives.
• Nesting of SOURCE Directives
The text introduced by a SOURCE directive can include one or more SOURCE directives. The
compiler processes nested SOURCE directives when it encounters them. The maximum nesting
depth is three; that is, at most three source files can be open at any given time as a
consequence of SOURCE directives (source files open in response to COPY statements are
not counted in this respect).
• Relationship Between SOURCE Directive and COPY Statement
The effect of the SOURCE directive is neither a subset nor a superset of the effect of the COPY
statement; they are completely independent.
The SOURCE directive does not provide a REPLACING capability.
The text that a COPY statement delivers can include one or more SOURCE directives. The text
that a SOURCE directive delivers can include one or more COPY statements. A COPY statement
is not permitted to deliver a SOURCE directive that delivers another COPY statement, because
this would create the effect of nested COPY statements.
A SOURCE 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.
• SOURCE Directive Behavior in IF/IFNOT/ENDIF Sequences
The compiler ignores a SOURCE directive specified within conditional text (within the scope
of an IF or IFNOT directive) if the controlling condition is false.
• Interaction of SOURCE and COLUMNS Directives
When a COLUMNS directive applies to the line or lines containing a SOURCE directive, the
same logical line length attribute is the default for the lines introduced in response to that
directive; however, a COLUMNS directive appearing within the designated file overrides the
default. In this circumstance, the compiler honors the “inner” logical line length for the remainder
of the text imported by the SOURCE directive, after which the “outer” logical line length
becomes active again.
• Effect of ANSI and TANDEM Format Specifying Directives
The source text format (ANSI or Tandem) which applies to the line or lines containing a
SOURCE directive is the default for the lines introduced in response to that directive; however,
ANSI or TANDEM directives appearing within lines read from the file (or ANSI or TANDEM
options specified in SECTION directives) take effect when encountered. These then apply to
subsequent lines until they are overridden, the end of the source file is reached, or the end of
a selected section is reached (which causes the compiler to revert to the default source format
before it resumes reading the next selected section). In all cases the “outer” source format
attribute becomes active again after processing of the SOURCE directive completes.
• Diagnostic Messages and SOURCE Directives
If the compiler cannot at least minimally process a SOURCE directive (because the edit-file-name
specified is invalid, or the file cannot be accessed, or the file is not an EDIT file, and so forth),
the compilation terminates.
Compiler Directives 571










