|
Yeah, you took the bait, didn't ya? (heh, heh!)
I thought for a minute or so before deciding to respond (and I'll probably
regret it later <g>), but... (donning asbestos suit):
> The main reason is that there is one less logical test inside the loop.
c DoU %EoF( FileName )
c Key ReadE FileName
c If not %EoF( FileName )
And the problem is??? I think it's pretty hard to miss the intent here.
And, unless someone tells me that the If statement after the ReadE is a CPU
hog, I can't see any costs. Also, the loop-ending EndDo always has the
EndIf right before it, and I document the two lines in the comment area with
"DoU %EoF( FileName )" and "If not %EoF( FileName )".
> I can't think of any case where I've wanted to enter a loop via DOU in the
case where there aren't any records.
In that case, you would probably _never_ use DOU, right? Because it isn't
just that you have no _records_ to process, it's the fact that you have no
work to do in the loop. Therefore, it would seem to follow that you would
always do a "priming" test before you enter the loop.
Sigh. I'm beginning to regret this already. WAIT! DON'T PRESS THAT SEND K
> -----Original Message-----
> From: Rich Duzenbury [SMTP:rduz@westernmidrange.com]
> Sent: Sunday, April 16, 2000 12:06 AM
> To: RPG400-L@midrange.com
> Subject: RE: RPG Indicators
>
> OH BOY.
>
> I don't know why I'm responding to this one. I think it's a religion
> thing...but here's my .02 anyway.
>
> I am a 'true believer' of doing the priming read, using the do-while loop,
> and then reading just before the enddo.
>
> Why do I think it's better? The main reason is that there is one less
> logical test inside the loop. EOF is checked once and only once in each
> iteration. Also, the loop is never entered if there are no records. I
> can't think of any case where I've wanted to enter a loop via DOU in the
> case where there aren't any records.
>
> In my opinion, it's RPG that is forcing this issue on us. If RPG were to
> have the ability to do the read and test on the same line, we'd all use
> DOW, I think with little question. In C-ish languages, we would write it
> thusly:
>
> while (readfile('OURFILE')==TRUE)
> {
> ... do our processing...
> }
>
> or perhaps
> while (readfile('OURFILE'))
> {
> ... do our processing...
> }
>
> Of course, the downside is that if you need to modify the read statement,
> you have to do it twice. The other rule of thumb I try to stick to is to
> have read loops no longer than can comfortably be seen on one SEU screen.
> If I have more processing than can be done 'between the reads', I
> typically move it into a subroutine.
>
> <donning my flameproof gear>
>
> Regards,
> Rich
>
>
> -----Original Message-----
> From: owner-rpg400-l@midrange.com [mailto:owner-rpg400-l@midrange.com]On
> Behalf Of Peter Dow
> Sent: Saturday, April 15, 2000 9:43 PM
> To: RPG400-L@midrange.com
> Subject: Re: RPG Indicators
>
>
> I agree Dan. This has the added advantage that using ITER makes sense,
> although it also has the disadvantage that you have to repeat the
> condition.
> If there are more conditions than just eof, it could be modified something
> like this:
>
> c Key Setll FileName
> c DoU %EoF( FileName )
> c Key ReadE FileName
> c If %EoF( FileName ) or
> c (a = b and c = d) or
> c e = f
> c leave
> c EndIf
> *** do stuff
> c EndDo
>
>
> Peter Dow
> Dow Software Services, Inc.
> 909 425-0194 voice
> 909 425-0196 fax
>
> ----- Original Message -----
> From: Bale, Dan <DBale@lear.com>
> To: <RPG400-L@midrange.com>
> Sent: Friday, April 14, 2000 12:07 PM
> Subject: RE: RPG Indicators
>
>
> > My preference is to just have one file input operation for the loop,
> i.e.:
> >
> > c Key Setll FileName
> > c DoU %EoF( FileName )
> > c Key ReadE FileName
> > c If not %EoF( FileName )
> > *** do stuff
> > c EndIf
> > c EndDo
> >
> > This has always worked for me.
> >
> > - Dan Bale
+---
| 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 mailing list archive is Copyright 1997-2025 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.