× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I know that I have regularly, though not frequently, wished for a Select
like statement where each "When" clause was evaluated, regardless of
whether the previous "When" clauses were true. So your example could be
done like this:

 MultiSelect; // Like Select except all "When" clauses are always
evaluated.
   When A=5;
      // take action 
   When A=7;
      // take different action
   When A=8;
      // take different action
   When A=5 OR A = 7 OR A=8;
       Except detail;
 EndMSl;

Another interesting related set of opcodes are Switch and Case. As
implemented in other languages, the Case statements are limited to
testing the results of the expression specified on the Switch statement,
which I often find limiting but still usable. The interesting thing
about Switch/Case is that if you don't put a Break statement at the end
of a Case block then the contents of the next Case block will be
executed without testing the Case. So in the following example, if A=5
then both actions A and B would occur.

 Switch A;
  Case 5;
    // take action A
  Case 7;
    // take action B
    Break;
  Case 8;
    // take action C
    Break;
 EndSw;

I don't know if I would want to request that Switch/Case be added to
RPG, but it might be interesting to have an opcode that was the opposite
of Break for use with Select. so the above example could be coded like
this:

 Select;
  When A=5;
    // take action A
    DontBreak;
  When A=7;
    // take action B
  When A=8;
    // take action C
 EndSl;

Joe Lee

>>> carolla@xxxxxxxxx 12/30/2004 08:18:30 >>>
Personally, I use If/Else/EndIf if there are only two possibilities,
and I only use the Else if there is something to do either way.  For
all other situations, I use Select/When/Other.  If I revise a program,
and there is an If/Else/EndIf that now has another possiblilty, I
replace it with Select/When/Other.  I don't make use of the ElseIf
clause.

But this brings up another idea I had.  Occasionally, I will encounter
a set of conditions that may or may not be true, and for each
condition, a different action must be taken, but if any one of the
conditions in the set are true, I want to do something in addition to
the different tasks for each one in the set.  ex.:

Select;
   When A=5;
      // take action 
       Except detail
   When A=7;
      // take different action
       Except detail;
    When A=8;
      // take different action
       Except detail;
EndSL;

In this snippet, I want to print the 'detail' exception format if A=5,
7 or 8, but not otherwise.  Wouldn't it be nice to have an 'EitherWay'
op, which was executed if any of the when clauses were true?  i.e.

Select;
   When A=5;
      // take action 
   When A=7;
      // take different action
    When A=8;
      // take different action
     EitherWay;
       Except detail;
EndSL;

Wacky idea?  What do you think?

On Wed, 29 Dec 2004 16:12:51 -0600, Kurt Anderson
<kjanderson@xxxxxxxxxxxxx> wrote:
> Is there a difference to these two types of condition checking?
> They seem identical in function at a high level, so I'm unsure if one
is
> better performance-wise or something.  I guess I'm looking for
something
> to distinguish the two so I know when to use one and when to use the
> other.
> 
> Thanks,
> 
> Kurt Anderson
> Application Developer
> Highsmith Inc.
> W5527 State Road 106, P.O. Box 800
> Fort Atkinson, WI 53538-0800
> TEL (920) 563-9571  FAX (920) 563-7395
> EMAIL kjanderson@xxxxxxxxxxxxx 
> 


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.