Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Evaluate statement in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
vinit_infy
Warnings : 1

New User


Joined: 07 Apr 2005
Posts: 43

PostPosted: Thu Apr 14, 2005 2:53 pm    Post subject: Evaluate statement in cobol
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
References
kanak

Moderator


Joined: 12 Mar 2005
Posts: 259
Location: India

PostPosted: Thu Apr 14, 2005 3:35 pm    Post subject:
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: 124

PostPosted: Thu Apr 14, 2005 7:22 pm    Post subject:
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

Global Moderator


Joined: 06 Jan 2004
Posts: 257

PostPosted: Thu Apr 14, 2005 11:45 pm    Post subject:
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: 102
Location: Navi Mumbai, India

PostPosted: Fri May 06, 2005 2:47 pm    Post subject:
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

Global Moderator


Joined: 06 Jan 2004
Posts: 257

PostPosted: Fri May 06, 2005 4:17 pm    Post subject:
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: 141

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

Ankur

Anu is Right and you are Wrong. Please test yourself OR check this example for more information.
http://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

Global Moderator


Joined: 06 Jan 2004
Posts: 257

PostPosted: Fri May 06, 2005 7:06 pm    Post subject:
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    Post subject:
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    Post subject:
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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1