Re: Data Name = to more than one number

From: Howard Brazee (howard_at_brazee.net)
Date: 02/10/04


Date: Tue, 10 Feb 2004 15:36:33 GMT


On 9-Feb-2004, klbjornme@aol.com (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'

I don't know what you mean by "easier".

I typically format that code (If I were to write it) as follows:
     IF ORDER-ITEM-SERIES = '1'
    OR ORDER-ITEM-SERIES ='2'
         PERFORM FIRST-DISC
     ELSE
          IF ORDER-ITEM-SERIES = '3'
         OR ORDER-ITEM-SERIES = '4'
         OR ORDER-ITEM-SERIES = '5'
               PERFORM SECOND-DISC
         END-IF
      END-IF.

The reason I do what I do is to facilitate adding conditions, commenting out
conditions, un-commenting out conditions, etc. It is also easy to see parallel
conditions.

Some people do this:
    IF ORDER-ITEM-SERIES="1' or '2'

This requires less typing, and is pretty clear. It doesn't allow me to comment
out a condition.

Some people do this:
    IF ORDER-ITEM-SERIES='1' OR
        ORDER-ITEM-SERIES='2'
This appears parallel, but commenting out conditions is a bit more work than
putting the OR parallel with the IF.

That said - for this particular coding need, I would have used an EVALUATE
statement. I'm assuming your code was illustrative rather than real -
otherwise I don't know why anybody wouldn't use EVALUATE here.



Relevant Pages

  • Re: Commenting the source code.
    ... Commenting the source code.'s a cool scene! ... Dig it! ... >>My theory is that commenting whilst you are coding, ... >>will break your concentration on what you were programming. ...
    (comp.lang.c)
  • Re: Current-driving a powerful IR-illuminator array
    ... "Summarize what you're following up. ... go to the BOTTOM of the article and start typing there. ... I wasn't commenting on the intelligibility, ...
    (sci.electronics.design)
  • Re: Commenting the source code.
    ... > My theory is that commenting whilst you are coding, ... > will break your concentration on what you were programming. ... refer back and forth to other files or documentation as I go, ...
    (comp.lang.c)
  • Re: Commenting the source code.
    ... "Rob Thorpe" wrote in message ... >> My theory is that commenting whilst you are coding, ... Something like this (for my Palm OS game) works for me: ...
    (comp.lang.c)
  • Re: Commenting the source code.
    ... > My theory is that commenting whilst you are coding, ... > will break your concentration on what you were programming. ... Also, as you say, writing comments may take your attention from the actual ... very burdensome commenting regime on you then it may slow you down ...
    (comp.lang.c)