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

Question on Evaluate Function in Cobol.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Amolondhe007
Warnings : 1

New User


Joined: 16 Apr 2007
Posts: 49
Location: Pune

PostPosted: Fri Mar 06, 2009 3:17 pm
Reply with quote

Hi,

Please let me know that Can we add AND Operator in Evaluate Function.

E.G.

Evaluate Color

When Red AND White * Here added AND Operator.

Display ' Good Combination '

When Other

Display ' No Combonation '

End-Evaluate.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Mar 06, 2009 3:36 pm
Reply with quote

If you had looked at the EVALUATE statement, you would have seen that AND is not valid, ALSO is the way to join.....
Back to top
View user's profile Send private message
Amolondhe007
Warnings : 1

New User


Joined: 16 Apr 2007
Posts: 49
Location: Pune

PostPosted: Fri Mar 06, 2009 3:50 pm
Reply with quote

Ok, William.

But if we are using any numeric value like
Code:
EVALUATE ANS 
WHEN 0.00 AND +64.00
      ADD +10.00 to +20.00 giving ANS.
      Display 'ANS: ' ANS.
WHEN OTHER
     Display 'INCORRECT VALUE'
END-EVALUATE.   



Then can it work?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Mar 06, 2009 5:03 pm
Reply with quote

Hi Amol,

What you're looking for is "OR" capability. The "AND" as you explain it in your ex. is impossible.

You should use:
Code:
WHEN 0.00
WHEN +64.00
     ADD +10.00 to +20.00 giving ANS
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Fri Mar 06, 2009 8:44 pm
Reply with quote

EVALUATE TRUE
WHEN ANS = 0.00 OR +64.00
ADD +10.00 to +20.00 giving ANS.
Display 'ANS: ' ANS.
WHEN OTHER
Display 'INCORRECT VALUE'
END-EVALUATE.
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 206
Location: Bangalore

PostPosted: Fri Mar 06, 2009 9:00 pm
Reply with quote

Hi,

EVALUATE subject
WHEN object1
WHEN object2
END-EVALUATE

Datatypes of both subject and object should match. If subject is TRUE or FALSE, then object1 and object2 must be condition expressions which should evaluate to True or False. Note: These conditons can contain AND.


Thanks,
Ajay
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Mar 08, 2009 8:38 pm
Reply with quote

Hi Ajay,
Quote:
Note: These conditons can contain AND.

I know you made the above correct stmt as a general comment, but it may mislead in the context of Amol's ques:
Code:
WHEN 0.00 AND +64.00
     ADD +10.00 to +20.00 giving ANS.

"AND" cannot be both values simultaneously.
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