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
 

 

EVALUATE in Cobol

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

New User


Joined: 15 Feb 2008
Posts: 22
Location: China

PostPosted: Tue May 27, 2008 7:54 am    Post subject: EVALUATE in Cobol
Reply with quote

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
View user's profile Send private message

the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Tue May 27, 2008 8:07 am    Post subject:
Reply with quote

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
View user's profile Send private message
amolghorpade

New User


Joined: 06 Oct 2005
Posts: 7

PostPosted: Tue May 27, 2008 8:17 am    Post subject:
Reply with quote

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
View user's profile Send private message
daye.Zheng

New User


Joined: 15 Feb 2008
Posts: 22
Location: China

PostPosted: Tue May 27, 2008 8:20 am    Post subject:
Reply with quote

the_gautam!

U sure?

I think so as you said.

But my leader tell me that is right!

so
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Tue May 27, 2008 8:30 am    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue May 27, 2008 12:41 pm    Post subject:
Reply with quote

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
View user's profile Send private message
jckraheja

New User


Joined: 19 May 2008
Posts: 13
Location: Pune

PostPosted: Tue May 27, 2008 2:49 pm    Post subject: Reply to: About EVALUATE in Cobol
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


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

PostPosted: Tue May 27, 2008 5:41 pm    Post subject:
Reply with 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:
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
View user's profile Send private message
Phrzby Phil

Active Member


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

PostPosted: Tue May 27, 2008 6:03 pm    Post subject:
Reply with quote

Such a simple thing to test, and so much incorrect malarky. This is not a professional way to learn or teach.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Tue May 27, 2008 6:20 pm    Post subject:
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


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

PostPosted: Tue May 27, 2008 6:26 pm    Post subject:
Reply with quote

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
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Wed May 28, 2008 7:40 am    Post subject:
Reply with quote

Yes, i am sorry for my wrong postings.
Actually i never came across such thing...
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Wed May 28, 2008 10:45 am    Post subject:
Reply with quote

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... icon_smile.gif .
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Wed May 28, 2008 11:16 am    Post subject:
Reply with quote

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
View user's profile Send private message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Wed May 28, 2008 3:13 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed May 28, 2008 3:41 pm    Post subject:
Reply with quote

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
View user's profile Send private message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Wed May 28, 2008 4:05 pm    Post subject:
Reply with quote

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 icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed May 28, 2008 4:56 pm    Post subject:
Reply with quote

Jasorn,
no, you are mistaken.

and I apologize for not spelling your name properly in the previous post.
Back to top
View user's profile Send private message
Sudhir Babu G

New User


Joined: 11 May 2011
Posts: 1
Location: India

PostPosted: Thu Jul 07, 2011 7:45 pm    Post subject:
Reply with quote

I think this may work

EVALUATE TRUE ALSO TRUE
WHEN A ALSO B
PERFORM C
END-EVALUATE.
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
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


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