IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Query on EVALUATE


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Mon Oct 12, 2009 4:33 pm
Reply with quote

Hi can anyone explain the execution of EVALUATE statement?

EVALUATE TRUE
WHEN VAR-A IS NUMERIC
PERFORM read file A

WHEN VAR-B IS NUMERIC
PERFORM read file B
END-EVALUATE

If both the variables ( VAR-A and VAR-B) are numeric, then what 'll happen... whether both the files 'll be read or file A alone?

Thanks in advance
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Oct 12, 2009 4:41 pm
Reply with quote

/RANT ON/
why can't you read the description provided in ANY COBOL manual?
/RANT OFF/

IBM Manuals button at top-of-page, does not matter the version,
EVALUATE has not changed.
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Mon Oct 12, 2009 4:44 pm
Reply with quote

I think that the first one will get execute
Back to top
View user's profile Send private message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Mon Oct 12, 2009 4:46 pm
Reply with quote

yeah u r right.. but i don't find the ans that is related to my question.. if u knew please share it..


Thanks..
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Oct 12, 2009 4:51 pm
Reply with quote

The manuals link at the top of the page does not take long to click -- nor does it take long to find the COBOL Language Reference manual -- nor does it take long to find the EVALUATE statement in the manual where it reads
Quote:
6.2.13.4 Executing the EVALUATE statement

After the comparison operation is completed, execution of the EVALUATE statement proceeds as follows:

* If a WHEN phrase is selected, execution continues with the first imperative-statement-1 following the selected WHEN phrase. Note that multiple WHEN statements are allowed for a single imperative-statement-1.

* If no WHEN phrase is selected and a WHEN OTHER phrase is specified, execution continues with imperative-statement-2.

* If no WHEN phrase is selected and no WHEN OTHER phrase is specified, execution continues with the next executable statement following the scope delimiter.

* The scope of execution of the EVALUATE statement is terminated when execution reaches the end of the scope of the selected WHEN phrase or WHEN OTHER phrase, or when no WHEN phrase is selected and no WHEN OTHER phrase is specified.


If you cannot use the manual to find such a clear statement, or cannot understand such a clear statement, perhaps you should reconsider your career choice -- IT has many, many, many times when things are much more complex than this and you will be expected to understand from your reading which applies, and why.
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Mon Oct 12, 2009 4:52 pm
Reply with quote

I think , not sure but evaluate works like whenever the first condition get satisfy it comes out of the evaluate , so as soon as the first condition get satify then it will execute that and comes out
Back to top
View user's profile Send private message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Mon Oct 12, 2009 4:59 pm
Reply with quote

Yes Ketan.. i tooo have a thought that if anyone of the condition given in the WHEN clause is true the execution 'll come out of the EVALUATE statement after executing the imperative statements...
but i need to get clarified on this...
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Oct 12, 2009 5:06 pm
Reply with quote

Sigh.
Quote:
* If a WHEN phrase is selected, execution continues with the first imperative-statement-1 following the selected WHEN phrase.
says the first WHEN that is TRUE will have its statement(s) executed.
Quote:
* The scope of execution of the EVALUATE statement is terminated when execution reaches the end of the scope of the selected WHEN phrase or WHEN OTHER phrase, or when no WHEN phrase is selected and no WHEN OTHER phrase is specified.
says once the statement(s) for the WHEN have been executed, control passes out of the EVALUATE.

Extremely clear in the manual -- reading and comprehension are optional.
Back to top
View user's profile Send private message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Mon Oct 12, 2009 5:14 pm
Reply with quote

yes....
but here we are not not checking the same variable for different conditions instead we are checking two different variables...
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Oct 12, 2009 5:31 pm
Reply with quote

pecram24 wrote:
yes....
but here we are not not checking the same variable for different conditions instead we are checking two different variables...


number of variables that you are testing does not matter.

the order of the WHEN clauses is what matters:
First one satisfied, is the only one that is executed.

if you need to check two different variables
and do something for each, then evaluate is the incorrect command.
Back to top
View user's profile Send private message
pecram24

New User


Joined: 12 Oct 2009
Posts: 35
Location: Chennai

PostPosted: Mon Oct 12, 2009 5:43 pm
Reply with quote

Hi all thank u for your answers...
i just wanted to confirm whether my understanding is correct or not....

Thanks,
Ram
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Oct 12, 2009 5:52 pm
Reply with quote

Quote:
i just wanted to confirm whether my understanding is correct or not....


you are welcome.
We realize that such a complex question requires continual expansive explanations;
especially since something like this is so difficult to test.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top