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



Joe,
Tried it 'elseif'. That did not work. Then put it back the way it was and low 
and behold it worked. We have compaired the two codes and they look the same. 
I would like to think everyone for there help and comments.
Willie...

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of AGlauser@xxxxxxxxxxxx
Sent: Thursday, May 25, 2006 12: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
#####################################################################################

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.