COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-98
INSPECT TALLYING
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 is no next compare-string. When there is no next
compare-string, the character position in source-string immediately to
the right of the leftmost character position considered in the last comparison
cycle is considered to be the leftmost character position, and the comparison
cycle begins again with the first compare-string.
3. Whenever a match occurs, tallying occurs as described in Tallying. The
character position in source-string immediately to the right of the
rightmost character position that participated in the match is now considered to
be the leftmost character position of source-string, and the comparison
cycle resumes with the first compare-string.
4. The comparison operation continues until the rightmost character position of
source-string has participated in a match or has been considered to be
the leftmost character position. When this occurs, inspection terminates.
5. If the CHARACTERS phrase appears, an implied 1-character operand
participates in the comparison cycle, except that no comparison to the contents
of source-string occurs. This implied character is considered to match the
leftmost character of source-string participating in the current comparison
cycle.