COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-99
INSPECT TALLYING
•
BEFORE and AFTER Phrases
The BEFORE and AFTER phrases affect the comparison operation like this:
1. If no BEFORE or AFTER phrase is present, compare-string or the
operand implied by CHARACTERS participates in the comparison operation.
2. If the BEFORE phrase appears, the associated compare-string or the
operand implied by CHARACTERS participates only in comparison cycles that
involve the portion of source-string from its leftmost character position up
to, but not including, the first occurrence of delim-string. The position of
this first occurrence is determined before the first cycle of the comparison
operation begins.
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 participates in the comparison operation as though the
BEFORE phrase was not specified.
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.