View previous topic :: View next topic |
Author |
Message |
gans79 Beginner
Joined: 31 Aug 2005 Posts: 51 Topics: 27
|
Posted: Mon Jul 10, 2006 3:42 am Post subject: Multiple Whens in Evaluate |
|
|
hi,
I need to know what happens when there are multiple when in a evaluate
stmt,
ex:
Code: |
EVALUATE TRUE
WHEN VARW > 0
WHEN VARX > 0
WHEN VARY > 0
WHEN VARZ > 0
ADD 1 TO VARA
END-EVALUATE
|
here VARA will be incremented if all the conditions satisfy or even if one condition satisfy ?
thanks
ganesh |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
gans79 Beginner
Joined: 31 Aug 2005 Posts: 51 Topics: 27
|
Posted: Mon Jul 10, 2006 4:34 am Post subject: |
|
|
Hi kolusu,
I went through the topic , but i was not able to get a clear answer to my
question, can u let me know the answer to my question
thanks
ganesh |
|
Back to top |
|
|
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Mon Jul 10, 2006 5:04 am Post subject: |
|
|
gans79,
Try this code :
Code: |
WORKING-STORAGE SECTION.
01 VARA PIC 9(1) VALUE 0.
01 VARW PIC 9(1) VALUE 0.
01 VARX PIC 9(1) VALUE 0.
01 VARY PIC 9(1) VALUE 0.
01 VARZ PIC 9(1) VALUE 1.
PROCEDURE DIVISION.
0000-MAIN.
EVALUATE TRUE
WHEN VARW > 0
WHEN VARX > 0
WHEN VARY > 0
WHEN VARZ > 0
ADD 1 TO VARA
DISPLAY 'VARA IS ' VARA
WHEN OTHER
DISPLAY 'OTHER'
END-EVALUATE.
|
In this case VARW ,VARX and VARY are all set to 0 and if they are greater than 0 , no action is being taken whereas when VARZ is greater than 0 i am adding 1 to VARA and displaying it.So only condition when is satisfied is WHEN VARZ > 0.However if you initialize VARZ to 0 and try running the code , you will get the output displayed as OTHER because none of the WHEN conditions met for displaying anything.Hope this helps. _________________ Shekar
Grow Technically |
|
Back to top |
|
|
Elroy Beginner
Joined: 30 Jun 2006 Posts: 4 Topics: 2
|
Posted: Mon Jul 10, 2006 8:12 am Post subject: |
|
|
It sounds like you just want to AND them together?
WHEN VARW > 0 AND VARX > 0 AND VARY > 0 AND VARZ > 0 |
|
Back to top |
|
|
blitz Beginner
Joined: 24 Dec 2002 Posts: 28 Topics: 4
|
Posted: Tue Jul 11, 2006 6:04 am Post subject: |
|
|
AND or OR?!? |
|
Back to top |
|
|
chandresha Beginner
Joined: 20 Dec 2005 Posts: 1 Topics: 0
|
Posted: Thu Jul 13, 2006 6:48 am Post subject: |
|
|
Hi ,
This EVALUATE is equivalent to
If VARW > 0 OR VARX > 0 OR VARY > 0 OR VARZ > 0
ADD 1 TO VARA
END-IF.
Hope this helps !
Chandresh |
|
Back to top |
|
|
|
|