Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Can "EVALUATE" execute all conditions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Lalitha Hima Bindu

New User


Joined: 06 Jul 2007
Posts: 5
Location: Chennai

PostPosted: Mon Jan 21, 2008 12:07 pm    Post subject: Can "EVALUATE" execute all conditions
Reply with quote

Here is my question?

Q1. What will be the output for the below code:
:

working-storage section.

77 A PIC 9 VALUE IS 1.

:

:

PROCEDURE DIVISION.

EVALUATE TRUE

WHEN A <2

DISPLAY "CASE2"

WHEN A = 1

DISPLAY "CASE1"

WHEN OTHER

DISPLAY "OTHER"

END-EVALUATE.

A: CASE2

Q2. What will be the output for the below code:

:

:

working-storage section.

77 A PIC 9 VALUE IS 1.

:

PROCEDURE DIVISION.

EVALUATE TRUE

WHEN A = 1

DISPLAY "CASE1"

WHEN A <2

DISPLAY "CASE2"

WHEN OTHER

DISPLAY "OTHER"

END-EVALUATE.

A: CASE1

But in my Program, I like to change the way how EVALUATE statement functions. i.e. I like to execute EVALUATE all conditions and like to take the last satisfied condition.

Is it possible, if so how ?

Thanks in Advance
Lalitha.
Back to top
View user's profile Send private message

ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Mon Jan 21, 2008 12:15 pm    Post subject:
Reply with quote

Hi.

Quote:
I like to change the way how EVALUATE statement functions. i.e. I like to execute EVALUATE all conditions and like to take the last satisfied condition


What does this mean?

EVALUATE always evaluates the satisifed condition. It can be first one or last one. If first one only satisfies, other condition won't be executed.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Mon Jan 21, 2008 12:33 pm    Post subject:
Reply with quote

Lalitha,

Use seperate IF loops.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Mon Jan 21, 2008 1:15 pm    Post subject: Reply to: Can "EVALUATE" execute all conditions
Reply with quote

Lalitha,

Hi and welcome to the forums.

Quote:
What will be the output for the below code:


Why don't you test by coding the same?

As told, the control comes out of the EVALUATE loop as soon as the condition is satisfied. Use IF/THEN or EVALUATE based on your requirements.
Back to top
View user's profile Send private message
Lalitha Hima Bindu

New User


Joined: 06 Jul 2007
Posts: 5
Location: Chennai

PostPosted: Mon Jan 21, 2008 1:27 pm    Post subject: Reply to: Can "EVALUATE" execute all conditions
Reply with quote

I heard "EVALUATE" can handle multiple conditions also. In the sense for Q1 even though the first When satisfies, still it will execute the second when and it will display the O/P as "CASE1". But I donot knowhow to achieve this using Evaluate.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Mon Jan 21, 2008 2:16 pm    Post subject:
Reply with quote

Hi Lalitha,

As mentioned by Aaru

Quote:
As told, the control comes out of the EVALUATE loop as soon as the condition is satisfied.


In order to acheive o/p as "CASE1"
- Either u have to change the order of when clause in Evaluate
- Or use IF- ELSE
Back to top
View user's profile Send private message
varunvasudevan

New User


Joined: 10 Jan 2008
Posts: 4
Location: Chennai

PostPosted: Mon Jan 21, 2008 5:30 pm    Post subject: Reply to: Can "EVALUATE" execute all conditions
Reply with quote

Hi Lalitha,
u have heard that EVALUATE will handle multiple condition.That s true but u have taken it in wrong meaning.Normally the IF condion can handle only two condions ie true or false.
if (cond)
........
else
.....
end-if.
otherwise u can use AND/OR with if statment.Other option is u should go for nested if statements.

But EVALUATE will handle multiple conditions by specifying conditions in WHEN clause.You can use one EVALUTE statement with multiple when coditions.
And regarding ur question, once a WHEN condition satisfies ,the control will exit from EVALUATE statment and it will go to next statement.So i think u should go for another command to take only the last satisfied condition.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jan 21, 2008 7:57 pm    Post subject:
Reply with quote

Hi Lalitha,

Quote:
I heard "EVALUATE" can handle multiple conditions also.


Don't listen to rumors, use the manuals.
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Mon Jan 21, 2008 8:56 pm    Post subject:
Reply with quote

hi Lalitha,
as far as a single EVALUATE statement is concerned, it can execute only one successful WHEN clause. if there are more than one WHEN clauses in the EVALUATE structure which satisfies the condition mentioned with the EVALUATE clause, the first satisfying WHEN clause is executed and the control moves to the END-EVALUATE statement. it does not check the other WHEN clauses as soon as one WHEN clause is executed.
Back to top
View user's profile Send private message
mnnarayankar

New User


Joined: 21 Jan 2008
Posts: 24
Location: bangalore

PostPosted: Thu Jan 24, 2008 3:44 pm    Post subject:
Reply with quote

Hi Lalitha,

In EVELUTE if any of the WHEN CONDITION is satisfied then pointer automatically come out of the END-EVALUATE statement.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts RC 20 for Address ISPEXEC "ISRED... pkmurali CLIST & REXX 3 Sun Apr 16, 2017 11:30 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Amount field is getting corrupted whe... thesumitk SYNCSORT 5 Tue Oct 18, 2016 8:20 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us