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

EVALUATE statement in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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
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
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: 2146
Location: At my coffee table

PostPosted: Tue May 27, 2008 5:41 pm
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

Senior Member


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

PostPosted: Tue May 27, 2008 6:03 pm
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

Superior Member


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

PostPosted: Tue May 27, 2008 6:20 pm
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: 2146
Location: At my coffee table

PostPosted: Tue May 27, 2008 6:26 pm
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
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

Superior Member


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

PostPosted: Wed May 28, 2008 10:45 am
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
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
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Wed May 28, 2008 3:13 pm
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
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
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Wed May 28, 2008 4:05 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top