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:
evaluate-subject-nis a literal, data element, arithmetic expression or conditional expression.condition-nis a condition name described in a level 88 statement.statement-nis an imperative statement.
General Rules:
evaluate-subject-ncan be a literal, data element, arithmetic expression or conditional expression.evaluate-subject-1follows theEVALUATEstatement, and serves as the basis of comparison for all subsequentWHENcondition statements- The
EVALUATEsubject can combine multipleevaluate-subject-nby means of theALSOphrase. - When the
ALSOphrase is used, in anEVALUATEstatement,WHENstatements must contain an equal number ofALSOphrases , which all must testTRUEagainst theALSOstatements in the same ordinal position in theEVALUATEstatement in order for theWHENstatement to testTRUE. When-conditionis evaluated againstevaluate-subject. Ifwhen-conditiontestsTRUE, thenstatement-1is executed.- If
when-conditiondoes not testTRUEwhen matched withevaluate-subject, then subsequentWHENstatements are evaluated. - If no
WHENstatements testsTRUE, and aWHEN OTHERstatement exists, then theWHEN OTHERcondition isTRUE, andstatement-2executes. - If a
WHENclause is empty, it tests false, and the nextWHENstatement is evaluated. - If no
WHEN OTHERstatement exists, then theEVALUATEstatement ends, and control passes to the next statement in the program. THRUandTHROUGHare synonyms.- The
THRUphrase operates with the same General Rules as theTHRUphrase applied to theVALUEclause. - The
NOTphrase causes all values to testTRUEthat are not in the range of values following theNOTphrase. - The
ANYphrase testsTRUEfor 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