COBOL Manual for TNS and TNS/R Programs
Source Text Manipulation
HP COBOL Manual for TNS and TNS/R Programs—522555-006
10-4
COPY Statement
Usage Considerations:
•
Where COPY Statements Can Be Used
With these exceptions, a COPY statement can occur anywhere in the source text
that a character-string or separator can occur:
°
A COPY statement cannot appear within the body of another COPY statement.
°
A COPY statement cannot appear within source text that is introduced by
another COPY statement or a REPLACE statement.
°
If the word COPY appears either in a comment-entry or in a place where a
comment-entry can appear, it is considered part of the comment-entry, not as
the keyword that begins a COPY statement.
°
The keyword COPY must be preceded by a space character, unless it
immediately follows the indicator field.
°
A COPY statement cannot appear on the same line as an SQL/MP or SQL/MX
statement.
°
All four characters of the keyword COPY must appear on the same source text
line. The remainder of the statement can extend across additional program text
lines, in accordance with the continuation conventions of the reference format.
•
How the Compiler Processes a COPY Statement
The compiler processes a source program that includes COPY statements as
though the compiler included a preprocessor that performs these operations in this
order:
1. Locates each COPY statement
2. Replaces the COPY statement with the appropriate (and possibly edited)
library text
3. Passes the resulting text to the compiler proper
The effect of processing a COPY statement is to copy the specified library text into
the source program. The copied text logically replaces the entire COPY statement,
beginning with the keyword COPY and ending with the punctuation character
period.
If the source line on which the COPY statement begins contains other text
preceding the word COPY, the compiler attempts to combine that portion of the line
with the first library text line.
If the source line on which the COPY statement ends contains other text following
the terminating period, the compiler attempts to combine that portion of the line
with the last library text line.