Compaq AAQ2G1FTK Marine Radio User Manual


 
Using the STRING, UNSTRING, and INSPECT Statements
5.3 Examining and Replacing Characters Using the INSPECT Statement
When an active argument finds a match, the compiler ignores any remaining
arguments in the list and conducts the TALLYING or REPLACING operation
on the character. The scanner moves to a new position and the next inspection
operation begins with the first argument in the list. The INSPECT statement can
contain additional conditions, which are described later in this section; without
them, however, the argument match is allowed to take place, and inspection
continues following the match.
The compiler updates the scanner by adding the size of the matching argument to
it. This moves the scanner to the next character beyond the string of characters
that matched the argument. Thus, once an active argument matches a string of
characters, the statement does not inspect those character positions again unless
program control executes the entire statement again.
5.3.5 The TALLYING Phrase
An INSPECT statement that contains a TALLYING phrase counts the
occurrences of various character strings under certain stated conditions. It
keeps the count in a user-designated item called a tally counter.
5.3.5.1 The Tally Counter
The identifier following the word TALLYING designates the tally counter. The
identifier can be subscripted or indexed. The data item must be a numeric integer
without any editing or P characters; it can be COMP or DISPLAY usage, and it
can be signed (separate or overpunched).
Each time the tally argument matches the delimited string being inspected, the
compiler adds 1 to the tally counter.
You can initialize the tally counter to any numeric value. The INSPECT
statement does not initialize it.
5.3.5.2 The Tally Argument
The tally argument specifies a character-string (or strings) and a condition under
which that string should be compared to the delimited string being inspected.
The CHARACTERS form of the tally argument specifies that every character in
the delimited string being inspected should be considered to match an imaginary
character that serves as the tally argument. This increments the tally counter by
a value that equals the size of the delimited string. For example, the following
statement causes TLY to be incremented by the number of characters that
precede the first comma, regardless of what those characters are:
INSPECT FIELD1 TALLYING TLY FOR
CHARACTERS BEFORE ",".
The ALL and LEADING forms of the tally argument specify a particular
character-string (or strings), which can be represented by either a literal or
an identifier. The tally argument character-string can be any length; however,
each character of the argument must match a character in the delimited string
before the compiler considers the argument matched.
A literal character-string must be either nonnumeric or a figurative constant
(other than ALL literal). A figurative constant, such as SPACE or ZERO,
represents a single character and can be written as " " or 0 with the same
effect.
524 Using the STRING, UNSTRING, and INSPECT Statements