× 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.



What do you do with BLUE-GREEN?

No really, personally, I don't know if I like this.  Just my opinion, code
should be uniform.  But too each their own.  No criticism from me.

Michael Schutte



                                                                           
             "Rex Capio"                                                   
             <rex_capio@swimwe                                             
             ar-anywhere.com>                                           To 
             Sent by:                  "'RPG programming on the AS400 /    
             rpg400-l-bounces@         iSeries'" <rpg400-l@xxxxxxxxxxxx>   
             midrange.com                                               cc 
                                                                           
                                                                   Subject 
             05/25/2006 04:10          RE: Having both if/else executing   
             PM                        at the same time                    
                                                                           
                                                                           
             Please respond to                                             
              RPG programming                                              
              on the AS400 /                                               
                  iSeries                                                  
             <rpg400-l@midrang                                             
                  e.com>                                                   
                                                                           
                                                                           




I find no advantage of using one over the other, but I use them both to
break the monotony.
Examples:
             select:
             when color = 'BLUE';
                         if shade = 'MIDNIGHT';
                                     (do midnight blue processing)
                         elseif shade = 'NAVY';
                                     (do navy blue processing)
                         else;
                                     (do other blue processing)
                         endif;
             when color = 'RED';
                         if shade = 'BLOODY';
                                     (do bloody red processing)
                         elseif shade = 'GERANIUM';
                                     (do geranium red processing)
                         else;
                                     (do other red processing)
                         endif;
             other;
                         if shade = 'WHITE';
                                     (do white processing)
                         elseif shade = 'EARTH';
                                     (do earth processing)
                         else;
                                     (do other color processing)
                         endif;
             endsl;

or the other way around (select/when/endsl is inside if/elseif/endif).

Another example to break monotony:

             if color = 'RED';
                         (do red)
             elseif color = 'BLUE';
                         (do blue)
             else;
                         (do other colors)
             endif;

             select;
             when status = 'A';
                         (do A)
             when status = 'C';
                         (do C)
             other;
                         (do other)
             endsl







-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of AGlauser@xxxxxxxxxxxx
Sent: Thursday, May 25, 2006 3:36 PM
To: RPG programming on the AS400 / iSeries
Subject: RE: Having both if/else executing at the same time

Willie,

Have you stepped through the code?  Any new information to pass on?


Joe,

I'm interested in your reasons for using select/when over if/elseif.  I
think I prefer if/elseif only because I learned about them first, and to
me case-like statements should fall through like they do in C.  It seems
redundant to me to have both structures behave identically, and awkward to
have to do:

if (A)
  // do A stuff
endif;

if (B);
  // do B stuff
endif;

if (NOT (A OR B));
  // some sort of error
endif;

when what I'd like to do is:

select;
   when A;
      // do A stuff

   when B;
      // do B stuff
      leave;

   other;
      // some sort of error

endsl;

I realize that you're not advocating one method over the other, but I've
heard people say that it is 'better' to use select/when instead of
if/elseif, but they never provide any good reasons.  Do you have any, or
does it just feel more natural the way if/elseif does to me?

Adam


rpg400-l-bounces@xxxxxxxxxxxx wrote on 25/05/2006 02:53:47 PM:

> Actually, the original code simply selected among three mutually
exclusive
> conditions.  Using an ELSEIF doesn't change the outcome at all.
>
> IF CondA;
>   DoA;
> ELSE;
>   IF CondB;
>     DoB;
>   ELSE;
>     DoC;
>   ENDIF;
> ENDIF;
>
> Is functionally equivalent to:
>
> IF CondA;
>   DoA;
> ELSEIF CondB;
>   DoB;
> ELSE;
>   DoC;
> ENDIF;
>
> The ELSEIF just removes the second "endif" (which you accidentally left
in
> your post, Bob, LOL!).  This is also functionally equivalent to:
>
> SELECT;
>   WHEN CondA;
>     DoA;
>   WHEN CondB;
>     DoB;
>   OTHER;
>     DoC;
> ENDSL;
>
> Nowadays I tend towards the third form if there are more than two
mutually
> exclusive conditions.
>
> It should be noted that the three conditions being selected among are
> (CondA), ((NOT CondA) and (CondB)), and finally ((NOT CondA) and (NOT
> CondB)).  That is, even if both CondA and CondB are true, only the first
> branch of the code will be executed.
>
> Joe
>
>
> > From: Bob Cozzi
> >
> > ELSE and IF are two statements. In your code the only time the second
IF
> > will be
> > performed is when the first IF fails. Why? Because the first ELSE is
only
> > going
> > to be run if the first IF fails. Otherwise it'll jump to the ENDIF
> > statements.
> > I think what you really mean to have is ELSEIF not "ELSE" and "IF".
> > Replace the ELSE and IF with ELSEIF, and then take a look as this
page:
> >
> > www.rpgiv.com/blueribbon.html
> >
> >   if %len(%trim(APIErrMsg)) > 0;
> >      W#ERFL = *ON;
> >      W#MSDT = 'Error #' + APIErrMsg + ' receiving data from ' +
> >               'data queue.  Detail:  ' + APIErrDta;
> >    elseif %trim(itmInfo) = '';
> >       W#ERFL = *ON;
> >       W#MSDT = 'Invalid data received from data queue: ' +
> >             itmInfo ;
> >    else;
> >        uMATNO = jMATNO;
> >        uSIZE = jSIZE;
> >        uTEMPER = jTEMPER;
> >        uINSUL = jINSUL;
> >        uTENSIL = jTENSIL;
> >    endif;
> >    endif;
>
>
> --
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list
> To post a message email: RPG400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: RPG400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.
>

############################################################################

#########
Attention:
The above message and/or attachment(s) is private and confidential and is
intended
only for the people for which it is addressed. If you are not named in the
address
fields, ignore the contents and delete all the material. Thank you. Have a
nice day.

For more information on email virus scanning, security and content
management, please contact administrator@xxxxxxxxxxxx
############################################################################

#########
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.