COBOL Manual for TNS/E Programs (H06.03+)
Procedure Division Verbs
HP COBOL Manual for TNS/E Programs—520347-003
9-91
INSPECT TALLYING
3. If the AFTER phrase appears, the associated compare-string or the
operand implied by CHARACTERS can participates only in comparison cycles
that involve the portion of source-string following the first occurrence of
delim-string. The position of the first occurrence of delim-string. is
determined before the first cycle of the comparison operation begins. The
portion of source-string following the first occurrence of delim-string
begins with the character position immediately to the right of the rightmost
character of the first occurrence of delim-string and ends with the
rightmost character of source-string.
If, on any comparison cycle, compare-string or the operand implied by
CHARACTERS is not eligible to participate, it is not considered to match the
contents of source-string. If delim-string does not occur within
source-string, its associated compare-string or the operand implied by
CHARACTERS is not eligible to participate in the comparison operation.
•
Tallying
The INSPECT statement does not initialize tally. During the inspection of
source-string, each properly matched occurrence of compare-string is
tallied, using these rules:
°
If the ALL phrase appears, tally is incremented by one for each occurrence
of compare-string matched within source-string.
°
If the LEADING phrase appears, tally is incremented by one for each
contiguous occurrence of compare-string matched within source-
string, provided that the leftmost such occurrence is at the point where
comparison began in the first comparison cycle in which compare-string
was eligible to participate.
°
If CHARACTERS appears, tally is incremented by one for each character
matched within source-string.
In the Example 9-35
, INSPECT TALLYING checks for spaces in a data item. If spaces
are present (J-TALLY is greater than 0), the code reports an error.
Example 9-35. INSPECT TALLYING With One Compare-String
MOVE ZERO TO J-TALLY
INSPECT JOB-CLASS TALLYING J-TALLY FOR ALL SPACES
IF J-TALLY GREATER THAN 0
MOVE 0 TO J-TALLY
MOVE 3 TO MESSAGE-INDEX
PERFORM PRINT-ERROR
ELSE
MOVE 1 TO FLAG
END-IF










