Re: Regarding EVALUATE TRUE



On 8/15/2007 at 1:03 PM, in message
Yes, I know that the language definition of EVALUATE includes the
order of the WHEN statements; but depending on the ordering in an
EVALUATE just seems to me to be not in the spirit of what a "case"
construct should be about.

All in all, I think that it is a very bad idea to use EVALUATE TRUE
with WHEN condition-1 and WHEN condition-2 and WHEN condition-3 where
condition-1, condition-2, and condition-3 refer to separate data-
elements.

I don't think anyone ever claimed that

EVALUATE TRUE
WHEN condition_1
<statement>
WHEN condition_2
<statement>
END-EVALUATE

is the same as

IF condition_1
<statement>
END-IF
IF condition_2
<statement>
END-IF

I would never write the former if the latter was required for the exact
reason you state.

I am curious on your opinion about the following:

EVALUATE TRUE
WHEN ICMMSTR-ACC-OWIRE-LIM NUMERIC
MOVE ICMMSTR-ACC-OWIRE-LIM TO WIRE-OUT-LIMIT
WHEN ICMMSTR-CMP-OWIRE-LIM NUMERIC
MOVE ICMMSTR-CMP-OWIRE-LIM TO WIRE-OUT-LIMIT
WHEN ICMMSTR-HDR-OWIRE-LIM NUMERIC
MOVE ICMMSTR-HDR-OWIRE-LIM TO WIRE-OUT-LIMIT
END-EVALUATE

The logic is to set WIRE-OUT-LIMIT to the value of the first of three
possible fields that has a valid numeric value. In other words, even if all
three ICMMSTR fields are numeric, WIRE-OUT-LIMIT should be set to the value
ICMMSTR-ACC-OWIRE-LIM. In other words, it is *dependant* on the
'short-circuit' logic of EVALUATE. I see nothing wrong with that.

Using IF END-IF IF END-IF IF END-IF would not accomplish what I want. On
the other had, IF ELSE IF ELSE IF would, but I much prefer the evaluate.

Oh, and before anyone comments, yes I know I "missed" the "WHEN OTHER". The
fact is that ICMMSTR-HDR-OWIRE-LIM is required to always be numeric, so I
could have just said "WHEN OTHER" for the last condition. For whatever
reason (I don't recall!) I chose to do it as shown above. If I were to do
it again I'd probably do WHEN OTHER, if only because it saves that final
condition check. Of course if that final value was not numeric I'd be in
big trouble, but it is data retrieved from a file, and it was validated on
input, so I think I'm pretty safe.

Frank

.



Relevant Pages

  • Re: Regarding EVALUATE TRUE
    ... The logic is to set WIRE-OUT-LIMIT to the value of the first of three ... three ICMMSTR fields are numeric, WIRE-OUT-LIMIT should be set to the value ... That 'whatever reason' might be 'because you have better habits than you ...
    (comp.lang.cobol)
  • Re: question concerning evaluate.
    ... >For some reason I thought there would be an implied "and" between the ... >two when statements but I can find no basis for this assumption. ... End-If ... assuming, of course, that the compiler does not have 'Color' as a ...
    (comp.lang.cobol)