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

Procedure Division Verbs
HP COBOL Manual for TNS/E Programs520347-003
9-89
INSPECT TALLYING
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.
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.