COBOL Manual for TNS and TNS/R Programs

Source Text Manipulation
HP COBOL Manual for TNS and TNS/R Programs522555-006
10-17
REPLACE Statement
6. The compiler continues its comparison operation until either the rightmost text-
word in the source program text (within the scope of the REPLACE statement)
has participated in a match or has been considered as a leftmost text-word and
participated in a complete comparison cycle.
Comment Lines and Blank Lines in Replacement Text
The matching operation ignores any comment lines or blank lines occurring in the
source program text. The compiler determines the sequence of text-words in the
source program text and in pseudo-text-1 by the rules for reference format.
The replacement operation copies comment lines or blank lines in pseudo-
text-2 into the source program text without change whenever it copies pseudo-
text-2 into the source program.
The compiler does replace a comment line or blank line in source program text if
that comment line or blank line appears within the sequence of text-words that
match pseudo-text-1.
Debugging Lines
You can put debugging lines in pseudo-text-1 or in pseudo-text-2. 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 apparent source text is replaced, any text-words of the
replacement text specified on debugging lines appear on debugging lines in the
final source text.
If a portion of the apparent source text that begins on a debugging line is replaced,
all text-words of the replacement text appear on debugging lines in the final source
text.
If the REPLACE statement itself begins on a debugging line, all replacement text,
except comment and compiler directive lines, appears on debugging lines.
Because debugging lines and continuation lines are mutually exclusive, the
compiler cannot introduce a continued text-word into the source text when the
preceding rules require it to appear on debugging lines.
Sensitivity to Reference Format
Because, when a REPLACE statement is in force, the compiler analyzes pseudo-
text (and source text) without the benefit of any contextual information, you must
observe the COBOL reference format rules carefully. In particular, the compiler
does not identify a comma, semicolon, or period character as a separator unless it
is followed by at least one space character.
Similarly, the compiler interprets the character sequence X/9 as one text-word
(presumably a PICTURE character-string) rather than as three text-words;
however, the compiler always considers a left parenthesis, right parenthesis, or
colon character to be a separator unless it appears within a nonnumeric literal.