View previous topic :: View next topic
|
Author |
Message |
paduchuri
New User
Joined: 03 Jan 2011 Posts: 32 Location: Hyderabad
|
|
|
|
Hi All,
I am strucked up in evaluate statement.I am not able to use multiple not in a when condition.see below example
Code: |
EVALUATE PIM
when 100
dispaly 'temp1'
when 200
dispaly 'temp2'
when not 120
dispaly 'temp3'
WHEN ( NOT 200 AND NOT 500 ) /*not working here*/
DISPLAY 'temp5'
END-EVALUATE.
|
i am getting the following error message
Code: |
28 IGYPS2048-S An invalid abbreviated relation condition was found.
|
Please can some one advise me how to use muliple not in a when condition
Regards,
Pavan. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
try this :
when not 200
when not 500
display 'temp5' |
|
Back to top |
|
|
paduchuri
New User
Joined: 03 Jan 2011 Posts: 32 Location: Hyderabad
|
|
|
|
As per my actual requirement ,number of when's will increase in that case so i am just wondering if there is any alternative
Regards,
pavan. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
nope. |
|
Back to top |
|
|
paduchuri
New User
Joined: 03 Jan 2011 Posts: 32 Location: Hyderabad
|
|
|
|
Code: |
EVALUATE PIM also pim1
when 100 also 200
dispaly 'temp1'
when 200 also 500
dispaly 'temp2'
when not 120 also 300
dispaly 'temp3'
WHEN ( NOT 200 AND NOT 500 ) also 200 /*not working here*/
DISPLAY 'temp5'
END-EVALUATE.
|
in the above case i cannot apply your method please advise |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Why not? "Nope" means no. Why are you worried about number of WHEN's?
Why don't you code it as a nested IF and forget the EVALUATE if you don't like it? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Pavan Kumar wrote: |
in the above case i cannot apply your method please advise
|
if all else fails, read the manual.
EVALUATE
WHEN ??
WHEN ??
DO SOMETHING
WHEN ??
DO SOMETHING
END-EVALUATE
is the syntax that you were provided,
yet you failed to use it.
there is a limit of 256 WHEN's within a single evaluate.
are you going to reach that limit? |
|
Back to top |
|
|
nigelosberry
New User
Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
How about writing it in a different manner?
i.e.
EVALUATE TRUE
...
....
WHEN PIM NOT = 200 OR 500
END-EVALUATE |
|
Back to top |
|
|
Jose Mateo
Active User
Joined: 29 Oct 2010 Posts: 121 Location: Puerto Rico
|
|
|
|
Good day to all!
Try this one;
EVALUATE PIM
when 100
dispaly 'temp1'
when 200 <------ Anything after this condition is NOT 200
dispaly 'temp2'
when not 120
dispaly 'temp3' <---Everything that is not 120 will end here
WHEN NOT 500 <--- At this point everything will be 120
DISPLAY 'temp5' <--- all 120
END-EVALUATE.
Is this what you want to do? I don't think so. |
|
Back to top |
|
|
paduchuri
New User
Joined: 03 Jan 2011 Posts: 32 Location: Hyderabad
|
|
|
|
Thanks to every one for your solutions.
Finally i want to go with nihalansari approach.
EVALUATE TRUE
...
....
WHEN PIM NOT = 200 OR 500
END-EVALUATE. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Has this been tested?
If the statement were an IF with a NOT/OR it would fail - every value would be not= to one or the other. I'm not sure about EVALUATE/WHEN and am not able to test this just now. . . |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
WHEN PIM NOT = 200 OR 500 |
DeMorgan's Laws. If PIM is 200, it is not 500. If PIM is 500, it is not 200. If PIM is anything else, it is not 200 nor 500. In other words, this IF test will always evaluate true, no matter what the value of PIM. Not to mention that this IF statement is NOT the equivalent of the o/p code.
Code: |
EVALUTE TRUE
WHEN PIM NOT = 200 AND PIM NOT = 500 |
is recommended to ensure those who come after will thoroughly understand the logic -- allowing implied conditions when using NOT is just begging for maintenance problems down the line. |
|
Back to top |
|
|
nigelosberry
New User
Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
dick scherrer wrote: |
Hello,
Has this been tested?
If the statement were and IF with a NOT/OR it would fail - every value would be not= to one or the other. I'm not sure about EVALUATE/WHEN and am not able to test this just now. . . |
Yes, that's right, Thanks!
Syntactically its correct to have OR there but it will not serve the purpose. I think the OR should be replaced by AND
something like:
Code: |
WHEN PIM NOT = 200 AND 500
display ' not 200 AND not 500' |
|
|
Back to top |
|
|
nigelosberry
New User
Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
I have created a test program and compiled(Not tested with real data but I feel it should do):
Code: |
WORKING-STORAGE SECTION.
....
01 PIM PIC S9(03) COMP-3.
.....
PROCEDURE DIVISION.
....
....
EVALUATE TRUE
....
....
WHEN PIM NOT = 200 AND 500
DISPLAY 'NOT 200 AND NOT 500'
END-EVALUATE |
and the assembler listing for this says:
Code: |
000038 WHEN
000488 F911 8028 A0A4 CP 40(2,8),164(2,10) PIM
00048E 4780 B1F0 BC 8,496(0,11) GN=12(0004A0)
000492 F911 8028 A0A0 CP 40(2,8),160(2,10) PIM
000498 4780 B1F0 BC 8,496(0,11) GN=12(0004A0)
00049C 47F0 B1F4 BC 15,500(0,11) GN=24(0004A4)
0004A0 GN=12 EQU *
0004A0 47F0 B1FE BC 15,510(0,11) GN=23(0004AE)
0004A4 GN=24 EQU *
000039 DISPLAY
0004A4 58F0 202C L 15,44(0,2) V(IGZCDSP )
0004A8 4110 A130 LA 1,304(0,10) PGMLIT AT +296
0004AC 0DEF BASR 14,15
0004AE GN=23 EQU *
0004AE GN=16 EQU * |
Its look ok to me. Let me know if something's missing as I HAVE NOT TESTED IT. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
nihalansari wrote: |
I have created a test program and compiled(Not tested with real data but I feel it should do):
Code: |
WORKING-STORAGE SECTION.
....
01 PIM PIC S9(03) COMP-3.
.....
PROCEDURE DIVISION.
....
....
EVALUATE TRUE
....
....
WHEN PIM NOT = 200 AND 500
DISPLAY 'NOT 200 AND NOT 500'
END-EVALUATE |
and the assembler listing for this says:
Code: |
000038 WHEN
000488 F911 8028 A0A4 CP 40(2,8),164(2,10) PIM
00048E 4780 B1F0 BC 8,496(0,11) GN=12(0004A0)
000492 F911 8028 A0A0 CP 40(2,8),160(2,10) PIM
000498 4780 B1F0 BC 8,496(0,11) GN=12(0004A0)
00049C 47F0 B1F4 BC 15,500(0,11) GN=24(0004A4)
0004A0 GN=12 EQU *
0004A0 47F0 B1FE BC 15,510(0,11) GN=23(0004AE)
0004A4 GN=24 EQU *
000039 DISPLAY
0004A4 58F0 202C L 15,44(0,2) V(IGZCDSP )
0004A8 4110 A130 LA 1,304(0,10) PGMLIT AT +296
0004AC 0DEF BASR 14,15
0004AE GN=23 EQU *
0004AE GN=16 EQU * |
Its look ok to me. Let me know if something's missing as I HAVE NOT TESTED IT. |
Yes, from the code it is operating as you say.
Whenever I code a "complex" condition, I always use parentheses. Here, I know that the NOT applies to both left and right of the condition, if I do this.
Code: |
WHEN PIM NOT = ( 200 AND 500 )
DISPLAY 'NOT 200 AND NOT 500'
END-EVALUATE
|
Otherwise, the compiler will always do something, and I'll have to think hard (or check) what it is the compiler does. Put in the parentheses, and you no longer have to worry that the compiler might not understand what you want. |
|
Back to top |
|
|
|