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

separators as a single space. The compiler ignores any comment or directive line in the
library text or in pseudo-text-1. The REPLACING phrase operand matches the library
text if the two sequences of text-words are equal, character for character.
3. If no match occurs, the compiler repeats the comparison with each successive
pseudo-text-1, identifier-1, word-1, or literal-1, if any, in the REPLACING
phrase until a match occurs or until it has compared each operand in the phrase to the
leftmost library text-word or text-words.
4. If the compiler compares all the REPLACING phrase operands without finding a match,
it copies the leftmost library text-word into the source program. Then the compiler uses
the next successive library text-word as the leftmost text-word and starts the comparison
cycle again with the first pseudotext-1, identifier-1, literal-1, or word-1
in the REPLACING phrase.
5. Whenever a match occurs between pseudo-text-1, identifier-1, literal-1,
or word-1, the compiler copies the corresponding pseudo-text-2, identifier-2,
literal-2, or word-2 into the source program. The compiler places the text-words
into the program according to the rules of the reference format specified in the COPY
statement or, if not specified, the reference format active before the statement. Then the
compiler uses the library text-word immediately following the matching library text as the
leftmost text-word and starts the comparison cycle again with the first pseudo-text-1,
identifier-1, literal-1, or word-1 in the REPLACING phrase.
6. The comparison operation ends after the rightmost text-word in the library text participates
either in a match or as a leftmost text-word in a complete comparison cycle.
Comment Lines in Replacement Text
The compiler copies any comment line in pseudo-text-2 into the source program unchanged.
Debugging Lines
You can put debugging lines in library text and in pseudo-text-2 or in pseudo-text-1.
Text-words within a debugging line participate in the comparison cycle as though the indicator
area did not contain a D or d.
If a portion of the library text is replaced by a pseudo-text-2, any text-words of the
replacement text specified on debugging lines appear on debugging lines in the resulting
source text.
If a portion of the library text that begins on a debugging line is replaced, all text-words of
the replacement text appear on debugging lines in the resulting source text.
If library text specified on debugging lines is copied without replacement, it appears on
debugging lines in the resulting source text.
A debugging line cannot contain embedded SQL/MP or SQL/MX statements.
Example 145 COPY Statement With REPLACING Phrases
COPY CUSTOMER REPLACING ==FULL NAME== BY ==Able X. Baker==
ADDRESS BY STREET-ADDRESS.
COPY Libraries
A COPY library is either a file in the EDIT format or an OSS ASCII text file. Its text can be merged
into a source program during compilation using a COPY statement. If the COPY statement contains
a REPLACING phrase, specified portions of library text can be replaced by specified new text
when the COPY statement copies the library text into the source program. With or without the
REPLACING phrase, the COPY statement does not change the COPY library.
COPY Libraries 505