- When both the TALLYING and REPLACING phrases are specified, the INSPECT
statement is executed as if an INSPECT TALLYING statement were specified,
immediately followed by an INSPECT REPLACING statement.
- The first comparand is compared with an equal number of leftmost contiguous
characters in the inspected item. The comparand matches the inspected characters
only if both are equal, character-for-character.
- If no match occurs for the first comparand, the comparison is repeated
for each successive comparand until either a match is found or all comparands
have been acted upon.
- If a match is found, tallying or replacing takes place, as described in
the following TALLYING/REPLACING phrase descriptions. In the inspected item,
the first character following the rightmost matching character is now considered
to be in the leftmost character position. The process described in rules 2
and 3 is then repeated.
- If no match is found, then, in the inspected item, the first character
following the leftmost inspected character is now considered to be in the
leftmost character position. The process described in rules 2 and 3 is then
repeated.
- If the CHARACTERS phrase is specified, an implied one-character item is
used in the process described in rules 2 and 3. The implied character is always
considered to match the inspected character in the inspected item.
- The actions taken in rules 1 through 6 (defined as the comparison cycle) are repeated until the rightmost character in the inspected
item has either been matched or has been considered as being in the leftmost
character position. Inspection is then terminated.
When the BEFORE or AFTER phrase is specified, the preceding rules are modified
as described in BEFORE and AFTER Phrases (All Formats).
Figure 1 is an example of INSPECT statement results.
Figure 1. Example of INSPECT Statement Execution Results