View previous topic :: View next topic
|
Author |
Message |
anujageorge
New User
Joined: 28 Mar 2007 Posts: 4 Location: Cochin
|
|
|
|
hi ,
plz tell what is the advantage and disadvantage of evaluate verb |
|
Back to top |
|
|
munikumar Currently Banned New User
Joined: 18 Apr 2007 Posts: 24 Location: India
|
|
|
|
EVALUATE is the case statement in COBOL.
You can validate a condition with multiple checkings. It will give you a cleare picture and more understandability. There are number of EVALUATE syntaxes that we can use.
For example,
EVALUATE TRUE
WHEN <condition1>
statement-1s
WHEN <condition2>
statement-2s
.
.
WHEN OTHER
statement-os
END-EVALUATE. |
|
Back to top |
|
|
anujageorge
New User
Joined: 28 Mar 2007 Posts: 4 Location: Cochin
|
|
|
|
what is its disadvantage |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
What makes you think there is a disadvantage? |
|
Back to top |
|
|
gauravgupta2808 Warnings : 1 New User
Joined: 31 May 2007 Posts: 31 Location: Chennai, India
|
|
|
|
Disadvantages against what ...
If i consider IF-ELSE & EVALUATE, then IF-ELSE affects readability if there are many comparisons.. There EVALUATE is better option. |
|
Back to top |
|
|
socker_dad
Active User
Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
|
|
|
|
EVALUATE clause is good, very good.
Stacks of IF ELSE END-IF, IF ELSE END-IF, ad naseum are not good (if you are lucky enough to actually find END-IF used....).
Make us happy, use EVALUATE!
Seriously, there are no disadvantages to using EVALUATE, unless your aim is to write code that is hard for maintenance programmers to understand. Personally, I'd rather wade through two screens of Evaluates than a page of IF/ELSE/END-IF. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Good programming practice also calls for your last WHEN being WHEN OTHER, with either legitimate "other" processing code, or an error indicator if every possible case has been defined by the previous WHEN's, even if you know they have been.
No one will complain, quite the contrary, by the "extra" code. If nothing else, a future modification may screw up your perfect program. |
|
Back to top |
|
|
|