COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-97
INSPECT TALLYING
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
1. If source-string, compare-string, or delim-string is alphanumeric,
the INSPECT statement handles the contents of each of them as a character-
string.