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-n
is a literal, data element, arithmetic expression or conditional expression.condition-n
is a condition name described in a level 88 statement.statement-n
is an imperative statement.
General Rules:
evaluate-subject-n
can be a literal, data element, arithmetic expression or conditional expression.evaluate-subject-1
follows theEVALUATE
statement, and serves as the basis of comparison for all subsequentWHEN
condition statements- The
EVALUATE
subject can combine multipleevaluate-subject-n
by means of theALSO
phrase. - When the
ALSO
phrase is used, in anEVALUATE
statement,WHEN
statements must contain an equal number ofALSO
phrases , which all must testTRUE
against theALSO
statements in the same ordinal position in theEVALUATE
statement in order for theWHEN
statement to testTRUE
. When-condition
is evaluated againstevaluate-subject
. Ifwhen-condition
testsTRUE
, thenstatement-1
is executed.- If
when-condition
does not testTRUE
when matched withevaluate-subject
, then subsequentWHEN
statements are evaluated. - If no
WHEN
statements testsTRUE
, and aWHEN OTHER
statement exists, then theWHEN OTHER
condition isTRUE
, andstatement-2
executes. - If a
WHEN
clause is empty, it tests false, and the nextWHEN
statement is evaluated. - If no
WHEN OTHER
statement exists, then theEVALUATE
statement ends, and control passes to the next statement in the program. THRU
andTHROUGH
are synonyms.- The
THRU
phrase operates with the same General Rules as theTHRU
phrase applied to theVALUE
clause. - The
NOT
phrase causes all values to testTRUE
that are not in the range of values following theNOT
phrase. - The
ANY
phrase testsTRUE
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