View previous topic :: View next topic |
Author |
Message |
Hilltop Beginner
Joined: 14 Oct 2004 Posts: 62 Topics: 21
|
Posted: Fri Oct 07, 2005 1:48 am Post subject: Evaluate question |
|
|
Please look at the sample code..
Evaluate ws-1
when other
perform xyz
when 1
perform abc
End-evaluate
My question is which one gets executed first.
My answer would be when other, because execution will be from top to bottom.
Please let me know if you guys agrees with me.
Thanks. |
|
Back to top |
|
 |
acevedo Beginner

Joined: 03 Dec 2002 Posts: 127 Topics: 0 Location: Europe
|
Posted: Fri Oct 07, 2005 2:13 am Post subject: |
|
|
have you compiled your program? |
|
Back to top |
|
 |
Hilltop Beginner
Joined: 14 Oct 2004 Posts: 62 Topics: 21
|
Posted: Fri Oct 07, 2005 2:29 am Post subject: |
|
|
This was an interview question, currently I don't do coding at my shop. |
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Fri Oct 07, 2005 2:54 am Post subject: |
|
|
Hiltop,
You will end in a Compilation Error (RC 12). See the message below.
Code: |
15 IGYPS2140-S "OTHER" was found in a "WHEN" phrase of an "EVALUATE" statement. The statement was discarded.
17 IGYPS2072-S "WHEN" was invalid. Skipped to the next verb, period or procedure-name definition.
|
There should be atleast 1 WHEN condition before issuing WHEN OTHER.
Here is the code
Code: |
WORKING-STORAGE SECTION.
01 WS-LITERALS.
05 WS-CNT PIC X(01) VALUE ' '.
05 WS-EVALUATE-CNT PIC X(01) VALUE ' '.
PROCEDURE DIVISION.
MOVE '1' TO WS-CNT
MOVE WS-CNT TO WS-EVALUATE-CNT
EVALUATE WS-EVALUATE-CNT
WHEN OTHER
DISPLAY 'OTHER ...'
WHEN '1'
DISPLAY '1....'
END-EVALUATE.
STOP RUN.
|
Thanks,
Phantom |
|
Back to top |
|
 |
acevedo Beginner

Joined: 03 Dec 2002 Posts: 127 Topics: 0 Location: Europe
|
Posted: Fri Oct 07, 2005 3:20 am Post subject: |
|
|
exactly what I ment  |
|
Back to top |
|
 |
Hilltop Beginner
Joined: 14 Oct 2004 Posts: 62 Topics: 21
|
Posted: Fri Oct 07, 2005 4:02 am Post subject: |
|
|
Thanks a lot Phantom and Acevedo. |
|
Back to top |
|
 |
|
|