Condition Names - Range of Values Example


Scenario - Declaring condition name with a range of values using 88 level number.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       IDENTIFICATION DIVISION.
       PROGRAM-ID. LEVEL88R.
       AUTHOR. MTH.

       DATA DIVISION.
       WORKING-STORAGE SECTION.

       01 WS-ALPHABET       PIC X(01) VALUE "1".
      * Condition name with Range of values
          88 VALID-ALPHABET VALUE "A" THROUGH "Z".

       PROCEDURE DIVISION.

           IF VALID-ALPHABET
              DISPLAY "Given Character is Alphabet"
           ELSE
              DISPLAY "Given Character is not Alphabet"
           END-IF.

           STOP RUN. 

Output -

Given Character is not Alphabet

Explaining Example -

In the above example:

  • WS-ALPHABET is declared as a single-byte alphanumeric variable. It has one condition names.
  • VALID-ALPHABET is a condition name with a range of values from "A" to "Z". If VALID-ALPHABET (i.e., IF WS-ALPHABET >= "A" AND WS-ALPHABET <= "Z") is satisifed, "Given Character is Alphabet" will be displayed. Otherwise, "Given Character is not Alphabet" will be displayed.