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

pseudo-text-2
can be null. A character-string within pseudo-text-2 can continue on the next line, but
both characters of the pseudo-text delimiter (==) must be on the same line.
text-word
is any character-string or separator, except space.
identifier-1, identifier-2
are identifiers of data items.
literal-1, literal-2
are literals (but not national literals). Neither can be a concatenation expression.
word-1, word-2
are COBOL words.
Usage Considerations:
Effect of REPLACE on Literals
The REPLACE statement does not affect literals; for example,
REPLACING ==Year== BY ==Month==
does not change the original text-word
"End of Year"
to the new text-word
"End of Month"
Matching Text in a COPY Library
The compiler searches for portions of text in the order you specify in the REPLACING phrase.
If you want to replace a sequence of text-words with something and a particular text-word
with something else, specify the sequence first. For example, if you want to replace all
occurrences of “XXX” with “BALANCE” and all occurrences of “XXX OF YYY” with “BALANCE
OF BUDGET-REC,” the REPLACING phrases must be in this order:
REPLACING "XXX OF YYY" BY "BALANCE OF BUDGET-REC"
"XXX" BY "BALANCE"
If you specify “XXX” first, the compiler first changes the “XXX” to “BALANCE,” producing
“BALANCE OF YYY;” therefore, it can never find the sequence “XXX OF YYY.
For purposes of matching, the compiler handles identifier-1, word-1, and literal-1
as pseudo-text containing only identifier-1, literal-1, or word-1, respectively.
Comparison Operation
The compiler determines which characters of source text to replace by comparing
pseudo-text-1, identifier-1, literal-l to text-words in the COPY library. This is
how the comparison operation works:
1. The compiler copies any separator comma, semicolon, and space that precedes the
leftmost library text-word into the source program.
2. Starting with the leftmost library text-word, the compiler compares all the text-words in
the first pseudo-text-1, identifier-1, literal-1, or word-1 to an equal number
of contiguous text-words in the library. During the comparison, the compiler handles each
occurrence of a separator comma or semicolon and each sequence of one or more space
504 Source Text Manipulation