OSVS 

The EXAMINE Statement

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

General Formats for Format 1


Syntax for format 1 of the EXAMINE Statement

General Formats for Format 2


Syntax for format 2 of the EXAMINE Statement

Syntax Rules for All Formats

  1. The identifier must be described, explicitly or implicitly, as USAGE IS DISPLAY.
  2. 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 for All Formats

  1. Examination proceeds as follows:
    1. 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.
    2. 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.
  2. The TALLYING option creates an integral count which replaces the value of a spe cial register called TALLY. The count represents the number of:
    1. Characters not equal to literal-1 encountered before the first occurrence of literal-1 when the UNTIL FIRST option is used.
    2. Occurrences of literal-1 when the ALL option is used.
    3. Occurrences of literal-1 prior to encountering a character other than literal-1 when the LEADING option is used.
  3. When either of the REPLACING options is used, the replacement rules are as follows:
    1. When the ALL option is used, then literal-2 is substituted for each occurrence of literal-1.
    2. 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.
    3. When the FIRST option is used, the first occurrence of literal-1 is replaced by literal-2.
    4. 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.