The EXAMINE Statement
The EXAMINE statement replaces or counts the number of occurrences of a given
character in a data item.
General Formats


Syntax Rules
- The identifier must be described, explicitly or implicitly, as USAGE IS DISPLAY.
- Each literal must consist of a single character. If identifier is a numeric
item, the literals must be numeric literals, nonnumeric literals whose value
is a single numeric digit, or the figurative constant ZERO. If identifier
belongs to any other class, then the literals can be numeric or nonnumeric,
or any figurative constant without the word ALL.
General Rules
- Examination proceeds as follows:
- For nonnumeric data items, examination starts at the leftmost character and
proceeds to the right. Each character in the data item specified by the identifier
is examined in turn.
- If a data item referred to by the EXAMINE statement is numeric, it must consist
of numeric characters and can possess an operational sign. Examination starts
at the leftmost character (excluding the sign) and proceeds to the right.
Each character except the sign is examined in turn. Regardless of where the
sign is physically located, it is completely ignored by the EXAMINE statement.
-
The TALLYING option
creates an integral count which replaces the value of a spe cial register
called TALLY. The count represents the number of:
- Characters not equal to literal-1 encountered before the first occurrence
of literal-1 when the UNTIL FIRST option is used.
- Occurrences of literal-1 when the ALL option is used.
- Occurrences of literal-1 prior to encountering a character other than literal-1
when the LEADING option is used.
- When either of the REPLACING options is used, the replacement rules are as
follows:
- When the ALL option is used, then literal-2 is substituted for each occurrence
of literal-1.
- When the LEADING option is used, the substitution of literal-2 terminates
as soon as a character other than literal-1 or when the right-hand boundary
of the data item is encountered.
- When the FIRST option is used, the first occurrence of literal-1 is replaced
by literal-2.
- When the UNTIL FIRST option is used, the substitution of literal-2 terminates
as soon as literal-1 or the right-hand boundary of the data item is encountered.