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

Procedure Division Verbs
HP COBOL Manual for TNS/E Programs520347-003
9-92
INSPECT TALLYING
In Example 9-36, an INSPECT TALLYING statement uses multiple compare-string
s. Some characters look as if they qualify as matches, yet are not counted, because a
character can be counted only once, no matter how many comparisons it can satisfy.
After execution of the INSPECT statement in Example 9-36, the counters have these
values:
Example 9-36. INSPECT TALLYING With Multiple Compare-Strings
WORKING-STORAGE SECTION.
01 INSPECT-COUNTERS.
03 COUNTER-1 PIC 99 VALUE 0.
03 COUNTER-2 PIC 99 VALUE 0.
03 COUNTER-3 PIC 99 VALUE 0.
03 COUNTER-4 PIC 99 VALUE 0.
03 COUNTER-5 PIC 99 VALUE 0.
77 ITEM-A PIC X(15) VALUE " 00001,003,200".
PROCEDURE DIVISION.
...
INSPECT ITEM-A TALLYING
COUNTER-1 FOR ALL "0",
COUNTER-2 FOR CHARACTERS BEFORE INITIAL ","
COUNTER-3 FOR LEADING " ",
COUNTER-4 FOR ALL "0" BEFORE INITIAL ",",
COUNTER-5 FOR ALL "0" AFTER INITIAL ","
Counter Value
COUNTER-1 8
COUNTER-2 3
COUNTER-3 0
COUNTER-4 0
COUNTER-5 0