What's the difference between EVALUATE and EVALUATE TRUE?
What's the difference between EVALUATE and EVALUATE TRUE?
Hi,
What's the difference between EVALUATE and EVALUATE TRUE in COBOL? I get confused about it. Please help.
What's the difference between EVALUATE and EVALUATE TRUE in COBOL? I get confused about it. Please help.
- Robert Sample
- Global Moderator
- Posts: 1903
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: What's the difference between EVALUATE and EVALUATE TRUE
The difference is mostly one of style since either can be converted to the other. Example:will execute the same as
Code: Select all
EVALUATE WS-X
WHEN (1)
<do something>
WHEN (2)
<do something else>
END-EVALUATE
Code: Select all
EVALUATE TRUE
WHEN (WS-X = 1)
<do something>
WHEN (WS-X = 2)
<do something else>
END-EVALUATE
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: What's the difference between EVALUATE and EVALUATE TRUE
Evaluate - Checks for value in variable and performs based on that
Eg
EVALUTE TRUE - Checks for TRUTHNESS in the logical expression and does action accordingly
Hope it clarifies
Edited
Eg
Code: Select all
EVALUATE WS-VAR
WHEN '1'
PERFORM …
WHEN '2'
PERFORM ...
WHEN OTHER
PERFORM ...
END-EVALUATE.
Code: Select all
EVALUATE TRUE
WHEN A = '1'
PERFORM
WHEN A = '2'
PERFORM
WHEN OTHER
PERFORM
END-EVALUATE
Edited
zprogrammer
Re: What's the difference between EVALUATE and EVALUATE TRUE
Thanks Robert and PB, with these examples - it helps me to understand this well.
Thank you,
Thank you,
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute