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
vinit_infy
Warnings : 1

New User


Joined: 07 Apr 2005
Posts: 56

PostPosted: Thu Apr 14, 2005 2:53 pm
Reply with quote

What is the difference between these two:

1) Evaluate True
When X
When Y And Z
Perform Para-1(For Example)
End-Evaluate

2) Evaluate True
When X
Continue
When Y And Z
Perform Para-1
End-Evaluate.

Regards,
Vinit
Back to top
View user's profile Send private message
kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Thu Apr 14, 2005 3:35 pm
Reply with quote

in the first case when X is true then it will perform para1, where as in 2nd expample, if the x is true then next exucatble statement will be executed which ever is present after end-evaluate.
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Thu Apr 14, 2005 7:22 pm
Reply with quote

In the first case para-1 executed and in the second one the statement next to the evaluate stmt executed.
Back to top
View user's profile Send private message
anuradha

Active User


Joined: 06 Jan 2004
Posts: 247
Location: Hyderabad

PostPosted: Thu Apr 14, 2005 11:45 pm
Reply with quote

Hi Vinit!

Quote:
1) Evaluate True
When X
When Y And Z
Perform Para-1(For Example)
End-Evaluate


In the above case if X is true or if (y and z) is true, (in either of the cases) para-1 will be performed.

Quote:
2) Evaluate True
When X
Continue
When Y And Z
Perform Para-1
End-Evaluate


In the above case if x is true the next executable statement will be executed which is present after End-Evaluate part. If y and z are true then para-1 will be performed.

HTH..
Back to top
View user's profile Send private message
ankyhunk

Moderator


Joined: 05 May 2005
Posts: 98
Location: Navi Mumbai, India

PostPosted: Fri May 06, 2005 2:47 pm
Reply with quote

Hi,
I differ with anu

Quote:
In the above case if X is true or if (y and z) is true, (in either of the cases) para-1 will be performed.


In the first case, when X is true & both Y & Z are true only then para-1 will be performed.
Back to top
View user's profile Send private message
anuradha

Active User


Joined: 06 Jan 2004
Posts: 247
Location: Hyderabad

PostPosted: Fri May 06, 2005 4:17 pm
Reply with quote

Quote:
I differ with anu

1) Evaluate True
When X
When Y And Z
Perform Para-1(For Example)
End-Evaluate

In the first case, when X is true & both Y & Z are true only then para-1 will be performed.


Hi Ankur,
Can you please check that again. Because this kind of code, we will be using in many programs. If i get time i will show you the proof also.
Back to top
View user's profile Send private message
somasundaran_k

Active User


Joined: 03 Jun 2003
Posts: 134

PostPosted: Fri May 06, 2005 6:35 pm
Reply with quote

Ankur

Anu is Right and you are Wrong. Please test yourself OR check this example for more information.
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/igy3pg10/1.5.1.1.2?DT=20020923143836#HDRWQ168

Regds
-Som
Back to top
View user's profile Send private message
anuradha

Active User


Joined: 06 Jan 2004
Posts: 247
Location: Hyderabad

PostPosted: Fri May 06, 2005 7:06 pm
Reply with quote

Hey Ankur,

Try to run this sample code and see the results:


Code:
WORKING-STORAGE SECTION.                           
        01 WH-HOLD-NUM  PIC 9(1).                         
        01 WH-HOLD-VAL1 PIC 9(1).                         
        01 WH-HOLD-VAL2 PIC 9(1).                         
        PROCEDURE DIVISION.                               
        MAIN-PARA.                                         
               MOVE 0                     TO WH-HOLD-NUM   
               EVALUATE WH-HOLD-NUM                       
                  WHEN 0                                   
                  WHEN 1                                   
                      MOVE 8              TO WH-HOLD-VAL1 
                  WHEN 2                                   
                      MOVE 3              TO WH-HOLD-VAL1 
               END-EVALUATE                               
               MOVE 1                     TO WH-HOLD-NUM   
               EVALUATE WH-HOLD-NUM                       
                  WHEN 0                                   
                  WHEN 1                                   
                     MOVE 8              TO WH-HOLD-VAL2   
                 WHEN 2                                     
                     MOVE 3              TO WH-HOLD-VAL2   
              END-EVALUATE                                 
              DISPLAY  WH-HOLD-VAL1.                       
              DISPLAY  WH-HOLD-VAL2.                       
              STOP RUN.                                     


Here is my proof:


Code:
********************************* TOP OF DATA ********************************
8                                                                             
8                                                                             
******************************** BOTTOM OF DATA ******************************
Back to top
View user's profile Send private message
nave

New User


Joined: 16 May 2005
Posts: 10
Location: bangalore,india

PostPosted: Mon May 16, 2005 6:34 pm
Reply with quote

i think what anu has showed is partially correct,since the first variable should be zero(WH-HOLD-VAL1=0) and the the second variable should be 8.that is my answer.

so in here the vineets quest what i answer is in the first case when y and z is true the perform statement works and in second case both x y z is true the para will be perfoermed,but i am still in doubtful with the default BREAK statement which is hidden with the each when clause,so what will be the effect of continue in the evaluate clause.plaease inform me if i am wrong
Back to top
View user's profile Send private message
nave

New User


Joined: 16 May 2005
Posts: 10
Location: bangalore,india

PostPosted: Mon May 16, 2005 6:34 pm
Reply with quote

hi anu ,vineet
i think what anu has showed is partially correct,since the first variable should be zero(WH-HOLD-VAL1=0) and the the second variable should be 8.that is my answer.

so in here the vineets quest what i answer is in the first case when y and z is true the perform statement works and in second case both x y z is true the para will be perfoermed,but i am still in doubtful with the default BREAK statement which is hidden with the each when clause,so what will be the effect of continue in the evaluate clause.plaease inform me if i am wrong
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