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

delim-string
is the identifier of an elementary item with USAGE DISPLAY or a nonnumeric literal.
It can be a figurative constant that does not include the keyword ALL, in which case
it represents one character.
ALL
specifies that all occurrences of compare-string are tallied.
LEADING
specifies scanning for consecutive occurrences of compare-string beginning at the
current position within source-string.
compare-string
is the identifier of an elementary data item with USAGE DISPLAY or a nonnumeric
literal. It can be a figurative constant that does not include the keyword ALL, in which
case it represents one character. The compare-string is the character-string being
sought.
Usage Considerations:
Definition of “Leading”
Characters are “leading” when they begin in the leftmost position of source-string and
have not satisfied another compare-string condition. For example, two leading As are
found in “AARDVARK” when
INSPECT ... FOR LEADING "A"
is coded, but no leading As are found in “AARDVARK” when
INSPECT ... FOR ALL "A" ... FOR LEADING "A".
is coded. The ALL phrase finds all three As, so none are left for the LEADING phrase to find.
(For a complete explanation of the logic of the comparison, see comparison operation.)
An example of LEADING ZERO is 00012.
National Data Items and National Literals
National data items and national literals cannot be used in an INSPECT statement.
How Parameter Categories Affect INSPECT
If source-string, compare-string, or delim-string is alphanumeric, the
INSPECT statement handles the contents of each of them as a character-string.
1.
2. If source-string, compare-string, or delim-string is alphanumeric edited,
numeric edited, or unsigned numeric, the source-string is inspected as though it had
been redefined as alphanumeric and the INSPECT statement had been written to refer to
the redefined item.
3. If source-string, compare-string, or delim-string is described as a signed
numeric, source-string is inspected as though it had been moved to an unsigned
numeric data item of the same length (excluding any separate sign), and then item 2
applies.
Comparison Operation
The comparison operation to determine the occurrences of compare-string works like
this:
1. Each tally is considered in the order specified in the INSPECT statement (reading from
left to right). The first compare-string is compared to an equal number of consecutive
characters of source-string, starting with source-string ’s leftmost character. If
the compare-string and the substring of source-string are equal, character for
character, then they match.
2. If no match occurs in the comparison of the first compare-string, the comparison is
repeated with each successive compare-string until either a match is made or there
INSPECT 347