|
(I'm not sure why I'm entering this debate... but...) James, I agree with your opnion on loops. I feel that the method of the priming read is a better way to do it, it makes the actual DOW loop do the work. I've always thought it was silly to test the same condition twice, or to defeat the actual looping mechanism by using LEAVE operations, although in the real world, sometimes LEAVE it necessary due to the complexity of your application, its best to try to avoid it. A loop with a priming read will execute less actual operations while the program is running, because it only tests the argument once per iteration of the loop. A loop where the read is done, and then a "LEAVE" statement is done upon failure is somewhat misleading, because it'll say something like "I'm going to do this until *IN10 is on" and then it doesn't actually use THAT to determine how long it does it... In fact, it wouldn't change your program to say "DOW 1=1" instead of "DOW *IN10=*OFF" since that'll always evaluate to TRUE... And therefore, your your ENDDO is nothing more than a GOTO back up to your DOW. Another argument for the priming read logic is that the condition of the loop is tested immediately after its SET. You don't have to search through the code to figure out if anything else might be tampering with the variables in your DOW condition in between the CHAIN/READE and the ENDDO. (Okay, now I've gotten involved in this debate, too... I must be a glutton for punishment) "James W. Kilgore" <qappdsn@ibm.net> wrote: > Dan, > > I see your point, but LEAVE is nothing more than a GOTO of a differe > color. > > Nesting an IF within a DO is like a double negative. You already ma > the test, > why test twice? > IMHO, that's why you'll find primed DOW loops with a bottom read so > common. > > First, the primed read determines if you need to enter the loop at > all, where a > DOU will always perform the loop once, thereby necessitating the inn > IF. Not to > mention the propensity to throw in a GOTO aka LEAVE. > > It's a style thing. > > James W. Kilgore > email@James-W-Kilgore.com > > P.S. I get a perverse kick out of the annual DOx debates that appear > on this list. > =8^) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This is the RPG/400 Discussion Mailing List! To submit a new * * message, send your mail to "RPG400-L@midrange.com". To unsubscribe * * from this list send email to MAJORDOMO@midrange.com and specify * * 'unsubscribe RPG400-L' in the body of your message. Questions should * * be directed to the list owner / operator: david@midrange.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
As an Amazon Associate we earn from qualifying purchases.
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.