View previous topic :: View next topic
|
Author |
Message |
daye.Zheng
New User
Joined: 15 Feb 2008 Posts: 22 Location: China
|
|
|
|
i got a COBOL evaluate question!
The code using "
Code: |
evaluate true
when a
when b
perform c
end-evaluate. '
replace if a or b
then perform c
end-if. |
My question is that can do ? |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
Code: |
EVALUATE TRUE
WHEN A
WHEN B
PERFORM C
END-EVALUATE. |
In this case, you are not doing anything when the first condition is satisfied.
So, the IF replacement should be -
Code: |
IF B
PERFORM C
END-IF. |
|
|
Back to top |
|
|
amolghorpade
New User
Joined: 06 Oct 2005 Posts: 7
|
|
|
|
the_gautam wrote: |
Code: |
EVALUATE TRUE
WHEN A
WHEN B
PERFORM C
END-EVALUATE. |
In this case, you are not doing anything when the first condition is satisfied.
So, the IF replacement should be -
Code: |
IF B
PERFORM C
END-IF. |
|
Hi Gautam,
I guess its the other way round.....
the replacing IF will be
IF (A or B)
PERFORM C
END-IF.
Regards,
Amol |
|
Back to top |
|
|
daye.Zheng
New User
Joined: 15 Feb 2008 Posts: 22 Location: China
|
|
|
|
the_gautam!
U sure?
I think so as you said.
But my leader tell me that is right!
so |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
According to the EVALUATE provided by you, the paragraph C is performed only if the the condition B is satisfied.
Code: |
EVALUATE TRUE
WHEN A
WHEN B
PERFORM C
END-EVALUATE. |
What has to be done when the first condition A is satisfied?
Note: Only one satisfied condition is executed in an EVALUATE.
And the IF, that you are talking is something like this -
Code: |
EVALUATE TRUE
WHEN A
PERFORM C
WHEN B
PERFORM C
END-EVALUATE.
or
EVALUATE TRUE
WHEN A OR B
PERFORM C
END-EVALUATE. |
[/b] |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Multilple WHEN phrases are allowed for single imparative statements.
the replace if logic is the IF (A or B) perform C.
and, please, look at the assembler generated from the evaluate. |
|
Back to top |
|
|
jckraheja
New User
Joined: 19 May 2008 Posts: 13 Location: Pune
|
|
|
|
Yes ....As Best of My knowledge......
EVALUATE TRUE
WHEN A
WHEN B
PERFORM C
END-EVALUATE.
Must be equal to :
IF A or B
PERFORM C
END-IF.
As, if any WHEN doesn't have any imperative sentence then successive next WHEN is also get executed.....So Perform C is executed any of the A or B is true.... [/quote] |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
the_gautam wrote: |
According to the EVALUATE provided by you, the paragraph C is performed only if the the condition B is satisfied. |
Wrong, and just to set the record straight:
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. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1049 Location: Richmond, Virginia
|
|
|
|
Such a simple thing to test, and so much incorrect malarky. This is not a professional way to learn or teach. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Quote: |
the_gautam wrote:
According to the EVALUATE provided by you, the paragraph C is performed only if the the condition B is satisfied.
Wrong, and just to set the record straight: |
Yup, I was going to say the same, not sure how in MST timings you get up this early CICS Guy..
This
Code: |
EVALUATE TRUE
WHEN A
WHEN B
Do something |
should be understood as
Code: |
Do something WHEN (A OR B) |
(This is just to understand, no such syntax exist.)
Well, this is little thing, could be tested with some DISPLAYs.. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Anuj D wrote: |
not sure how in MST timings you get up this early CICS Guy.. |
Five am is not that early, but I do fall asleep early too....grin..... |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
Yes, i am sorry for my wrong postings.
Actually i never came across such thing... |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
Quote: |
Actually i never came across such thing... |
There were many things which were never known to me for "came across" per se; well, I don't treat it as my fault, this is just because my work doesn't involve to work on "those" things. In such a situaion, if I get intrested in the topic, I experimented with the query in question & then posted the results here, that way I could learn good things, try this approach, might be helful for You as well..Good Luck... . |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
I didn't check the results on the system earlier. Whatever i posted earlier was as per my knowledge. When i saw others disagreeing on it, i tested it and found that i was wrong. |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
dbzTHEdinosauer wrote: |
Multilple WHEN phrases are allowed for single imparative statements.
the replace if logic is the IF (A or B) perform C.
and, please, look at the assembler generated from the evaluate. |
dbzTHEdinosauer,
Are you implying evaluate isn't very efficient and IF's are better in terms of effenciency? Or just that the assembler code would have shown the answer to this question? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Jason,
the later.
an Evaluate is just IF statements. the syntax makes it much easier to read and understand what would otherwise be nested/complex if statements.
Code: |
>>-EVALUATE--+-constant---+------------------------------------->
+-expression-+
+-reference--+
+-TRUE-------+
'-FALSE------'
.-----------------------------------.
| .---------. |
V V | |
>----WHEN--| any_clause |----command-+-+------------------------>
>--+--------------------------+--END-EVALUATE--;---------------><
| .---------. |
| V | |
'-WHEN--OTHER----command-+-'
any_clause
|--+-+-ANY-------+------------------------------------------+---|
| +-condition-+ |
| +-TRUE------+ |
| '-FALSE-----' |
'-+-----+--+-constant--+--+----------------------------+-'
'-NOT-' '-reference-' '-+-THROUGH-+--+-constant--+-'
'-THRU----' '-reference-' |
|
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
Dick,
I know but I use function upper-case because it's easier to read. Wasn't it you who posted that function upper-case isn't as efficient as 'the old way of converting case'? I thought you were raining on the 'easier to read' parade again |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Jasorn,
no, you are mistaken.
and I apologize for not spelling your name properly in the previous post. |
|
Back to top |
|
|
Sudhir Babu G
New User
Joined: 11 May 2011 Posts: 1 Location: India
|
|
|
|
I think this may work
EVALUATE TRUE ALSO TRUE
WHEN A ALSO B
PERFORM C
END-EVALUATE. |
|
Back to top |
|
|
|