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

Usage Considerations:
Comment Lines and Directive Lines in Pseudo-Text
Pseudo-text can contain comment lines and directive lines (that is, the text-words in pseudo-text
can be organized as comment lines and directive lines).
Where REPLACE Statements Can Be Used
With these exceptions, a REPLACE statement can occur anywhere in the source text that a
character-string can occur:
A REPLACE statement cannot appear within the body of another REPLACE statement.
A REPLACE statement cannot appear within source text introduced by another REPLACE
statement.
If the word REPLACE 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 REPLACE statement.
The keyword REPLACE must be preceded by a period separator, except when it begins
the first statement of a separately compiled program.
A REPLACE statement cannot appear on the same line as an SQL/MP or SQL/MX
statement.
All seven characters of the keyword REPLACE must appear on the same source text line. The
remainder of the statement can continue across additional program text lines, in accordance
with the continuation conventions of the reference format.
Persistence
A given occurrence of the REPLACE statement is active from the point at which you specify it
until the next occurrence of a REPLACE statement or the end of the separately compiled
program, respectively.
REPLACE Statements and the Listing
The listing the compiler produces shows the lines containing REPLACE statements like any other
lines. When any replacement occurs, the image in the listing is that of the text after replacement.
Order of Processing
Conceptually, the compiler processes any REPLACE statements in a source program after it
has processed any COPY statements.
Comparison Operation
The compiler determines which sequences of text-words to replace by comparing
pseudo-text-1 to text-words in the source text. This is how the comparison operation works:
1. Starting with the leftmost source program text-word and the first pseudo-text-1, the
compiler compares the word or words of pseudo-text-1 with the equivalent number
of contiguous text-words in the source program.
2. During the comparison, the compiler handles each occurrence of a separator comma or
semicolon and each sequence of one or more space separators as a single space. The
compiler ignores any comment or directive line in the source text or in pseudo-text-1.
The pseudo-text-1 matches the source 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 occurrence
of pseudo-text-1, if any, in the REPLACE statement until a match occurs or until it has
compared each operand in the pseudo-text-1 to the leftmost source program text-word
or text-words.
REPLACE Statement 509