Re: Data Name = to more than one number
From: JerryMouse (nospam_at_bisusa.com)
Date: 02/10/04
- Next message: Curtis Bass: "Re: Data Name = to more than one number"
- Previous message: Dimitris: "Re: Upgrade OCX"
- In reply to: KL: "Data Name = to more than one number"
- Next in thread: docdwarf_at_panix.com: "Re: Data Name = to more than one number"
- Reply: docdwarf_at_panix.com: "Re: Data Name = to more than one number"
- Reply: Howard Brazee: "Re: Data Name = to more than one number"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 10 Feb 2004 07:19:17 -0600
KL wrote:
> I need to know how to code when I have a data name that I want to use
> in an IF statement, but make it equal to more than one number. Is
> there an easier way to do this, other than the way I have in the
> following?
>
> IF ORDER-ITEM-SERIES = '1' OR ORDER-ITEM-SERIES ='2'
> PERFORM FIRST-DISC
> ELSE
> IF ORDER-ITEM-SERIES = '3' OR ORDER-ITEM-SERIES = '4'
> ORDER-ITEM-SERIES = '5'
> PERFORM SECOND-DISC
> ELSE
> CONTINUE
> END-IF.
> END-IF.
>
> As you can see, the nested IF statement becomes longer than 72, which
> makes it harder to code. I am just learning (well relearning, but
> it's been over 10 years). Any help would be greatly appreciated.
There are lots of ways.
Check out GO TO (A B C D E F) DEPENDING ON ORDER-ITEM-SERIES
(just kidding - if you use this ancient construct you will be skinned -
Check ALTER).
(just kidding again)
Anyway, Nested Ifs (as you have) are considered bad form, hard to understand
and maintain, and evidence sufficient of an addled thinking process. For
more than a couple of IFs, it is usually better to find a less confusing way
of accomplishing the same thing.
Doing different things based on the value of a single variable is the
defining case for EVALUATE as in:
EVALUATE ORDER-ITEM-SERIES
WHEN '1' thru '2' (do something)
WHEN '3' thru '4' (do something else)
WHEN '5' CONTINUE (don't do anything)
WHEN OTHER (do error processin)
END-EVALUATE
You really can't get more clear than that.
- Next message: Curtis Bass: "Re: Data Name = to more than one number"
- Previous message: Dimitris: "Re: Upgrade OCX"
- In reply to: KL: "Data Name = to more than one number"
- Next in thread: docdwarf_at_panix.com: "Re: Data Name = to more than one number"
- Reply: docdwarf_at_panix.com: "Re: Data Name = to more than one number"
- Reply: Howard Brazee: "Re: Data Name = to more than one number"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]