EVALUATE MyValue
WHEN 1
DISPLAY "My value is 1"
WHEN 2
DISPLAY "My value is 2"
WHEN OTHER
* Actually I don't need to do anything
END-EVALUATE
I think to have read somewhere that a COBOL application will crash for an EVALUATE
where the WHEN
clauses do not cover the value of the evaluated variable, if there is no WHEN OTHER
statement present. So, in order to avoid the crash, I wanted to add this empty WHEN OTHER
.
Under which circumstances is this necessary, and if so, is this approach correct?
Under which circumstances is this necessary
It is definitely necessary if the compiler ist configured to abort if the when other
statement ist missing. ;-)
Otherwise, in my opinion it is good practice to programm an when other
statement even if it only takes a continue
.