× 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: Anton Gombkötö <Gombkoetoe@xxxxxxxxxx>
  • Date: Thu, 20 Apr 2000 19:06:14 +0200

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
+---

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.