View previous topic :: View next topic
|
Author |
Message |
pecram24
New User
Joined: 12 Oct 2009 Posts: 35 Location: Chennai
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
/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 |
|
|
Ketan Varhade
Active User
Joined: 29 Jun 2009 Posts: 197 Location: Mumbai
|
|
|
|
I think that the first one will get execute |
|
Back to top |
|
|
pecram24
New User
Joined: 12 Oct 2009 Posts: 35 Location: Chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Ketan Varhade
Active User
Joined: 29 Jun 2009 Posts: 197 Location: Mumbai
|
|
|
|
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 |
|
|
pecram24
New User
Joined: 12 Oct 2009 Posts: 35 Location: Chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
pecram24
New User
Joined: 12 Oct 2009 Posts: 35 Location: Chennai
|
|
|
|
yes....
but here we are not not checking the same variable for different conditions instead we are checking two different variables... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
pecram24
New User
Joined: 12 Oct 2009 Posts: 35 Location: Chennai
|
|
|
|
Hi all thank u for your answers...
i just wanted to confirm whether my understanding is correct or not....
Thanks,
Ram |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
|