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


  • Subject: RE: DOU/DOW for READ Loops (My final word)
  • From: "Stone, Brad V (TC)" <bvstone@xxxxxxxxxxxxxx>
  • Date: Thu, 20 Apr 2000 13:38:41 -0500

Anton, 

Not stupid at all.  I agree 100%.  Any decent Comp Sci. curriculum will
teach you the "priming read" method of programming.  This is to, of course,
catch the fact that there are no records to be read.

Also, comp sci courses teach you that there should only be one exit point in
a loop.  Without the priming read, you're forced to have 2 exit points in a
loop.  The IF and the ENDDO in the DOU example, and an IF and the DOW if
done without a priming read.

These are basic fundamentals of good programming structure.

Now, while I don't use a priming read 100% of the time, I certain don't like
DOUs.  But that's just my eurodollar's worth of opinion.  :)

Brad

> -----Original Message-----
> From: Anton Gombkötö [mailto:Gombkoetoe@ASsoft.com]
> Sent: Thursday, April 20, 2000 12:06 PM
> To: RPG400-L@midrange.com
> Subject: Re: DOU/DOW for READ Loops (My final word)
> 
> 
> OK, i can't stand it any longer... thanks for the invitation!
> 
> Bill, you're completely right in the fact that one should 
> understand both.
> BUT:
> 
> > 1. I cringe every time I see the same file being read at 
> two different
> > points in a program.  I like to see an action happening 
> only once and only
> > at one point in the code.
> And i feel the same when i see the same condition twice, but 
> with different
> op-codes. More thinking necessary, at least for me.
> It's much clearer for me to have the read-operation (or 
> whatever) in one
> line and in the *very* next line the check whether there are 
> records or not.
> To be consequent,  i have to repeat the read before the 
> ENDDO. Of course in
> the very line before the ENDDO.
> 
> > 2. The second read statement that is coded at the end of 
> the DOW/ENDDO
> > construct always seems to me to be placed after the code.  
> I prefer to see
> > the read statement first, followed by the code that 
> operates on the data
> > read in.
> Of course is it placed after the code. It's quasi the next 
> cycle! And it's
> easier to read, maybe even for you, when you're honest: READ 
> (aha, a record
> is read) DOW (aha, when/as long records are there is 
> something performed)
> and then the READ with the ENDDO (read the next record and do 
> the same thing
> again, if there is still another record)
> 
> > 3. Using a DOU loop that "always executes at least once" makes sense
> > because I do want to always read the file at least once.
> OK, i do want that, too; but it's a programmer's fate to expect the
> unexpected - that there are no records (with the given key)! 
> And the DOW
> protects me a little bit.
> 
> Hopefully not too stupid 0.02 Euro
> 
> Anton Gombkötö
> 
> +---
> | This is the RPG/400 Mailing List!
> | To submit a new message, send your mail to RPG400-L@midrange.com.
> | To subscribe to this list send email to RPG400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to 
> RPG400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator: 
> david@midrange.com
> +---
> 
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

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.