Using the STRING, UNSTRING, and INSPECT Statements
5.3 Examining and Replacing Characters Using the INSPECT Statement
•
LEADING specifies that only adjacent matches of the search argument at
the leftmost position of the delimited character-string be replaced. At the
first failure to match the search argument, the compiler terminates the
replacement operation and causes the argument to become inactive.
•
FIRST specifies that only the leftmost character string that matches the
search argument be replaced. After the replacement operation, the search
argument containing this condition becomes inactive.
5.3.6.2 The Replacement Value
Whenever the search argument finds a match in the item being inspected, the
matched characters are replaced by the replacement value. The word BY followed
by an identifier or literal specifies the replacement value. For example:
INSPECT ITEMA REPLACING ALL "A" BY "X" ALL "D" BY "X".
The replacement value must always be the same size as its associated search
argument.
If the replacement value is a literal character-string, it must be either a
nonnumeric literal or a figurative constant (other than ALL literal). A figurative
constant represents as many characters as the length of the search argument
requires.
If the replacement value is an identifier, it must be an elementary item of
DISPLAY usage. It can be any class. However, if it is not alphanumeric, the
compiler conducts an implicit redefinition of the item. This redefinition is the
same as the BEFORE/AFTER redefinition discussed in Section 5.3.2.
5.3.6.3 The Replacement Argument
The replacement argument consists of the search argument (with its condition
and character-string), the replacement value, and an optional BEFORE/AFTER
phrase, as shown in Figure 5–5.
Figure 5–5 The Replacement Argument
BY
SPACE
Replacement
value
ZK−6054−GE
"."
BEFORE
BEFORE/AFTER
phrase (optional)
";"
ALL
Search
argument
5.3.6.4 The Replacement Argument List
One INSPECT...REPLACING statement can contain more than one replacement
argument. Several replacement arguments form an argument list, and the
manner in which the list is processed affects the action of any given replacement
argument.
The following examples show INSPECT statements with replacement argument
lists. The text following each one tells how that list will be processed.
Using the STRING, UNSTRING, and INSPECT Statements 5–31
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......