In my Cobol routine, I want to base only on the first byte of the variable PAR-STR PIC X(12)
from Linkage section to perform a different task (argument matching).
The compiler exits with the statement, that there is more than one object to evaluate in the statement.
DISPLAY PAR-STR.
EVALUATE PAR-STR(1:1)
WHEN 'P'
WHEN 'p'
PAR-STR = "X"
WHEN 'L'
WHEN 'l'
PAR-STR = "Y"
WHEN OTHER PAR-STR = "Z"
The compile result is giving me a problem, that there is no separation by also.
From my understanding, there is only one object to evaluate. Thus, unless there is a bug in the compiler, there is something of a cause of this proble that I'm not aware of..?
From the complier output:
000010 WHEN 'p'
==000010==> IGYPS2165-S Multiple "EVALUATE" objects were not separated by "ALSO". The statement
was discarded.
==000010==> IGYPS2133-S The number of "EVALUATE" subjects was less than the number of "EVALUATE"
objects. The statement was discarded.
==000010==> IGYPA3009-S The selection object at position 1 in the "WHEN" phrase did not match the
type of the corresponding selection subject in the "EVALUATE" statement.
The selection object was discarded.
Thanks for any hint about what could be the cause of this messages shown.
The compiler does mention that there is no ALSO, but finds there is an additional expression in the first WHEN (PAR-STR = "X"
).
The correct statements that work look accordingly:
DISPLAY PAR-STR.
EVALUATE PAR-STR(1:1)
WHEN 'P'
WHEN 'p'
MOVE "X" TO PAR-STR
WHEN 'L'
WHEN 'l'
MOVE "Y" TO PAR-STR
WHEN OTHER MOVE "Z" TO PAR-STR
END-EVALUATE.