Class Condition

The class condition determines whether the operand is numeric, or alphabetic

ANS85 or alphabetic-lower, or alphabetic-upper, or contains only the characters in the set of characters specified by the CLASS clause as defined in the Special-Names paragraph of the Environment Division.

General Format


*

Syntax Rules

  1. The class of an operand is determined as follows:
    1. An operand is numeric if it consists entirely of the characters 0,1, 2, 3, ... , 9, with or without an operational sign.
    2. An operand is alphabetic if it consists entirely of the upper-case letters A, B, C, ... , Z, space,

      ANS85 or the lower-case letters a, b, c, ... , z, space,

      or any combination of the upper-case

      ANS85 and lower-case

      letters and spaces.

    3. ANS85 An operand is alphabetic-lower if it consists entirely of the lower-case letters a, b, c, ... , z, and space.
    4. ANS85 An operand is alphabetic-upper if it consists entirely of the upper-case letters A, B, C, ... , Z, and space.
    5. ANS85 An operand conforms to class-name-1 if it consists entirely of the characters listed in the definition of class-name-1 in the Special-Names paragraph.
  2. Identifier-1 must reference a data item whose usage is explicitly or implicitly DISPLAY, or in the case of the NUMERIC test, is one of: DISPLAY,

    MF COMPUTATIONAL, COMPUTATIONAL-X,

    OSVSVSC2MFXOPEN COMPUTATIONAL-3

    MFXOPEN COMPUTATIONAL-5

    ANS85 or PACKED-DECIMAL.

  3. ANS85 If identifier-1 is a function-identifier, it must reference an alphanumeric

    MF or national

    function.

General Rules

  1. When the class condition does not include the word NOT and identifier-1 is a zero-length group item, the result of the class test is always false.

    When used, NOT and the next key word specify one class condition that defines the class test to be executed for truth value; e.g. NOT NUMERIC is a truth test for determining that an operand is nonnumeric. When the class condition includes the word NOT and identifier-1 is a zero-length group item, the result of the class test is always true.

    MF  The truth value of a class test involving a zero-length group item is reversed by the ZEROLENGTHFALSE Compiler directive.

  2. The NUMERIC test cannot be used with an item whose data description describes the item as alphabetic or as a group item composed of elementary items whose data description indicates the presence of operational sign(s). If the data description of the item being tested does not indicate the presence of an operational sign, the item being tested is determined to be numeric only if the contents are numeric and an operational sign is not present. If the data description of an elementary item being tested does indicate the presence of an operational sign, the item being tested is determined to be numeric only if the contents are numeric and a valid operational sign is present. Valid operational signs for data items described with the SIGN IS SEPARATE clause are the standard data format characters, "+" and "-"; valid operational signs for data items not described with the SIGN IS SEPARATE clause are described in the section Selection of Character Representation and Radix in the chapter Concepts of the COBOL Language.

    OSVSMF The NUMERIC test can be used with an item defined as a group item composed of elementary items whose data description indicates the presence of operational sign(s).

  3. The ALPHABETIC test cannot be used with an item whose data description describes the item as numeric. The item being tested is determined to be alphabetic only if the contents consist of any combination of the upper-case alphabetic characters "A" through "Z" and the space 

    ANS85 and any combination of the lower-case alphabetic characters "a" through "z"

    and the space.

    OSVSVSC2MF The class condition cannot be used for external floating-point (USAGE DISPLAY) or internal floating-point (USAGE COMP-1 and USAGE COMP-2) items.

  4. ANS85 The ALPHABETIC-LOWER test cannot be used with an item whose data description describes the item as numeric. The result of the test is true if the content of the data item referenced by identifier-1 consists entirely of the lower-case alphabetic characters "a" through "z" and space.
  5. ANS85 The ALPHABETIC-UPPER test cannot be used with an item whose data description describes the item as numeric. The result of the test is true if the content of the data item referenced by identifier-1 consists entirely of the upper-case alphabetic characters "A" through "Z" and space.
  6. MF The class-name-1 test must not be used with an item whose data description describes the item as numeric.