Skip to content

EVALUATE Statement

The EVALUATE Statement allows for different conditions to evaluated.

General Format:

       EVALUATE {evaluate-subject-1} [ ALSO {evaluate-subject-2} ] ... 
                {TRUE  }                    {TRUE  } 
                {FALSE }                    {FALSE } 
              { { WHEN when-condition-1 [ ALSO when-condition-2 ] ... } ... 
                     statement-1 } ... 
              [ WHEN OTHER 
                     statement-2 ] 
              [ END-EVALUATE ]

when-condition-n can be any of the following:

       {  ANY } 
       { (NOT] TRUE } 
       { [NOT] FALSE } 
       { [NOT] NUMERIC } 
       { [NOT] ALPHABETIC } 
       { [NOT] ALPHABETIC_LOWER } 
       { [NOT] ALPHABETIC_UPPER } 
       { [NOT] POSITIVE } 
       { [NOT] NEGATIVE } 
       { [NOT] = cond-obj } 
       { [NOT] EQUAL TO cond-obj } 
       { [NOT] EQUALS cond-obj } 
       { [NOT] = obj-value-1 {THRU   } obj-value-2 } 
                             {THROUGH} 
       { [NOT] >cond-obj } 
       { [NOT] GREATER THAN cond-obj } 
       { [NOT] <cond-obj } 
       { [NOT] LESS THAN cond-obj } 
       { [NOT] >= cond-obj } 
       { [NOT] GE cond-obj } 
       { [NOT] GREATER THAN OR EQUAL TO cond-obj } 
       { [NOT] <= cond-obj } 
       { IS [NOT] LESS THAN OR EQUAL TO cond-obj } 
       { < > cond-obj } 
       { < > cond-obj }

Syntax:

  1. evaluate-subject-n is a literal, data element, arithmetic expression or conditional expression.
  2. condition-n is a condition name described in a level 88 statement.
  3. statement-n is an imperative statement.

General Rules:

  1. evaluate-subject-n can be a literal, data element, arithmetic expression or conditional expression.
  2. evaluate-subject-1 follows the EVALUATE statement, and serves as the basis of comparison for all subsequent WHEN condition statements
  3. The EVALUATE subject can combine multiple evaluate-subject-n by means of the ALSO phrase.
  4. When the ALSO phrase is used, in an EVALUATE statement, WHEN statements must contain an equal number of ALSO phrases , which all must test TRUE against the ALSO statements in the same ordinal position in the EVALUATE statement in order for the WHEN statement to test TRUE.
  5. When-condition is evaluated against evaluate-subject. If when-condition tests TRUE, then statement-1 is executed.
  6. If when-condition does not test TRUE when matched with evaluate-subject, then subsequent WHEN statements are evaluated.
  7. If no WHEN statements tests TRUE, and a WHEN OTHER statement exists, then the WHEN OTHER condition is TRUE, and statement-2 executes.
  8. If a WHEN clause is empty, it tests false, and the next WHEN statement is evaluated.
  9. If no WHEN OTHER statement exists, then the EVALUATE statement ends, and control passes to the next statement in the program.
  10. THRU and THROUGH are synonyms.
  11. The THRU phrase operates with the same General Rules as the THRU phrase applied to the VALUE clause.
  12. The NOT phrase causes all values to test TRUE that are not in the range of values following the NOT phrase.
  13. The ANY phrase tests TRUE for all comparisons.

Code Sample:

       IDENTIFICATION DIVISION. 
       PROGRAM-ID. EVALUATE-1. 
       ENVIRONMENT DIVISION. 
       DATA DIVISION. 
       WORKING-STORAGE SECTION. 
       77 RANDOM-NUMBER     PIC9(9) VALUE 95. 
       77 DUMMY             PIC X. 
       PROCEDURE DIVISION. 
       MAIN. 
              EVALUATE RANDOM-NUMBER 
                     WHEN < 100 
                            DISPLAY "A SMALL RANDOM NUMBER: " LINE 5 COL 10 
                            DISPLAY RANDOM-NUMBER LINE 5 COL 32 
                     WHEN OTHER 
                            DISPLAY "A LARGE RANDOM NUMBER" LINE 5 COL 10 
                            DISPLAY RANDOM-NUMBER LINE 5 COL 32 
              END-EVALUATE. 

              DISPLAY "EVALUATE-1 FINISHED!" LINE 10 COL 10. 
              ACCEPT DUMMY LINE 10 COL 30. 

              STOP RUN
Back to top