MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

change the following IF condition to EVALUATE statement

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Thu Apr 22, 2004 11:36 am    Post subject: change the following IF condition to EVALUATE statement Reply with quote

Hi ,
Can u help me in changing the following IF condition using EVALUATE
Code:

IF (var-a     =  SPACES) OR   
    (var-b NOT = 'B')         
      SET K-MSG TO TRUE 
ELSE                       
      GO TO 2000-EXIT       
END-IF                     
Back to top
View user's profile Send private message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Thu Apr 22, 2004 11:47 am    Post subject: Reply with quote

sorry friends.I got it
Code:

EVALUATE TRUE                       
    WHEN VAR-A = SPACES             
         SET K-MSG TO TRUE         
    WHEN VAR-B NOT = 'B'           
         SET K-MSG TO TRUE         
    WHEN OTHER                     
         GO TO 2000-EXIT           
END-EVALUATE                       
                                   

VIjay
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Apr 22, 2004 11:57 am    Post subject: Reply with quote

vijay,

You can combine the first when into one condition
Code:

EVALUATE TRUE
   WHEN VAR-A     = SPACES
   WHEN VAR-B NOT = 'B'
        SET K-MSG TO TRUE
   WHEN OTHER
        GO TO 2000-EXIT
END-EVALUATE


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
JOHNCWL
Beginner


Joined: 25 Feb 2004
Posts: 31
Topics: 16

PostPosted: Fri Apr 30, 2004 8:24 am    Post subject: Reply with quote

Hi Kolusu,

I would like to know from performance point of view, whether IF -THEN-ELSE is better or Evaluate is better.

In the same context Any alternative to Perform statement in Cobol, to improve the performance??
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Fri Apr 30, 2004 8:43 am    Post subject: Reply with quote

Johncwl,

check this post which discusses good tips on writing efficient COBOL programs

http://www.mvsforums.com/helpboards/viewtopic.php?t=1485

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Fin
Beginner


Joined: 19 Jan 2004
Posts: 27
Topics: 8

PostPosted: Fri Jan 28, 2005 6:33 am    Post subject: Reply with quote

If I have a variable A and comparing it with B is this legal?

EVALUATE A
WHEN = WS-IN-CONTRACT-NUM
Do some processing
WHEN > B
Do other processing
WHEN < B
Do something else

Or - does there have to be an identifer or literal value straight after each 'WHEN'
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Fri Jan 28, 2005 8:14 am    Post subject: Reply with quote

Fin,

You syntax is not a valid syntax. try this

Code:

EVALUATE TRUE
   WHEN A = WS-IN-CONTRACT-NUM
        Do some processing
   WHEN A > B
        Do other processing
   WHEN A < B
        Do something else
END-EVALUATE


Hope this helps...

Cheers


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sun Jan 30, 2005 12:35 pm    Post subject: Reply with quote

Hi Fin,

You didn't define the variables, so my proposed solution may have to be adjusted to fit. I haven't tested this but it seems like it should work.

Just another way to skin this particular cat. Smile I wonder what a
performance comparison would show?
Code:

EVALUATE A
WHEN  WS-IN-CONTRACT-NUM
 Do some processing
WHEN  B + 1 THRU 999
 Do other processing
WHEN  0 THRU B - 1
 Do something else
END-EVALUATE

_________________
Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group