Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
daye.Zheng

New User

Joined: 15 Feb 2008
Posts: 22
Location: China

Posted: Tue May 27, 2008 7:54 am    Post subject: EVALUATE in Cobol

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 ?

the_gautam

Active User

Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

Posted: Tue May 27, 2008 8:07 am    Post subject:

 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.

New User

Joined: 06 Oct 2005
Posts: 7

Posted: Tue May 27, 2008 8:17 am    Post subject:

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
daye.Zheng

New User

Joined: 15 Feb 2008
Posts: 22
Location: China

 Posted: Tue May 27, 2008 8:20 am    Post subject: the_gautam! U sure? I think so as you said. But my leader tell me that is right! so
the_gautam

Active User

Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

Posted: Tue May 27, 2008 8:30 am    Post subject:

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]
dbzTHEdinosauer

Global Moderator

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

 Posted: Tue May 27, 2008 12:41 pm    Post subject: 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.
jckraheja

New User

Joined: 19 May 2008
Posts: 13
Location: Pune

 Posted: Tue May 27, 2008 2:49 pm    Post subject: Reply to: About EVALUATE in Cobol 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]
CICS Guy

Senior Member

Joined: 18 Jul 2007
Posts: 2149
Location: At my coffee table

Posted: Tue May 27, 2008 5:41 pm    Post subject:

 the_gautam wrote: According to the EVALUATE provided by you, the paragraph C is performed only if the the condition B is satisfied.
Phrzby Phil

Senior Member

Joined: 31 Oct 2006
Posts: 1012
Location: Richmond, Virginia

 Posted: Tue May 27, 2008 6:03 pm    Post subject: Such a simple thing to test, and so much incorrect malarky. This is not a professional way to learn or teach.
Anuj Dhawan

Senior Member

Joined: 22 Apr 2006
Posts: 6254
Location: Mumbai, India

Posted: Tue May 27, 2008 6:20 pm    Post subject:

 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..
CICS Guy

Senior Member

Joined: 18 Jul 2007
Posts: 2149
Location: At my coffee table

Posted: Tue May 27, 2008 6:26 pm    Post subject:

 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.....
the_gautam

Active User

Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

 Posted: Wed May 28, 2008 7:40 am    Post subject: Yes, i am sorry for my wrong postings. Actually i never came across such thing...
Anuj Dhawan

Senior Member

Joined: 22 Apr 2006
Posts: 6254
Location: Mumbai, India

Posted: Wed May 28, 2008 10:45 am    Post subject:

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... .
the_gautam

Active User

Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

 Posted: Wed May 28, 2008 11:16 am    Post subject: 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.
jasorn
Warnings : 1

Active User

Joined: 12 Jul 2006
Posts: 184
Location: USA

Posted: Wed May 28, 2008 3:13 pm    Post subject:

 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?
dbzTHEdinosauer

Global Moderator

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

Posted: Wed May 28, 2008 3:41 pm    Post subject:

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-'
jasorn
Warnings : 1

Active User

Joined: 12 Jul 2006
Posts: 184
Location: USA

 Posted: Wed May 28, 2008 4:05 pm    Post subject: 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
dbzTHEdinosauer

Global Moderator

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

 Posted: Wed May 28, 2008 4:56 pm    Post subject: Jasorn, no, you are mistaken. and I apologize for not spelling your name properly in the previous post.
Sudhir Babu G

New User

Joined: 11 May 2011
Posts: 1
Location: India

 Posted: Thu Jul 07, 2011 7:45 pm    Post subject: I think this may work EVALUATE TRUE ALSO TRUE WHEN A ALSO B PERFORM C END-EVALUATE.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Missing Negative sign in COBOL jzhardy COBOL Programming 6 Sat Sep 26, 2020 11:32 am COBOL reading from SYSIN jzhardy COBOL Programming 1 Mon Sep 21, 2020 2:37 pm how to read accounting information in... jzhardy COBOL Programming 1 Mon Sep 21, 2020 9:57 am NOT IN clause in COBOL pgm mramvivek COBOL Programming 8 Thu Aug 20, 2020 4:48 am Restart logic by using cursor name in... Twinkle22 Mainframe Interview Questions 1 Wed Jul 29, 2020 11:26 am

 © 2003-2020 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us