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

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.
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
348 Procedure Division Verbs