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



I think that the reason a lot of people do the " DOW 1 = 1" thing is to
avoid doing 2 read (one before the DOW and one before the ENDDO). I can
understand that (even if this is not my choice).

A long time ago, I saw in another language (LISP) a construct that I
liked very much and that solves this problem. It could look something
like this in RPG

LoopBegin
do stuff
LoopCondition not %eof
do stuff
LoopEnd

In a DOW the loop test is done at the DOW statement
In a DOU the loop test is done at the ENDSO statement

With the above structure, the loop test is done at the LoopCondition
statement which can be placed anywhere between LoopBegin and LoopEnd.

With this approch, a DOW would look like this:

LoopBegin
read file
LoopCondition not %eof
do stuff
LoopEnd

A DOU would look like this:

LoopBegin
reaf file
do stuff
LoopCondition not %eof
LoopEnd

Maybe it is just me but I like the fact that the test for the looping
has it's own statement independant of the start or beginning of the loop
itself.

This is only theory since this does not exist in RPG. But I wanted to
share my tougth (since it is friday afternoon)

Denis Robitaille
Directeur services technique TI
819 363 6130

SUPPORT
Jour (EST) Daytime : 819-363-6134
En-dehors des heures (EST) After hour : 819-363-6158
Network Status : 819-363-6157

Bryce Martin <BMartin@xxxxxxxxxxxx> 2009-01-09 14:04 >>>
why not something like....

read file;
dow not %eof;
do stuff
read file
enddo

No need for a second control structure if you do one read prior to
entering the loop.


Thanks
Bryce Martin
Programmer/Analyst I
Ext. 4777



"Jeff Crosby" <jlcrosby@xxxxxxxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
01/09/2009 01:38 PM
Please respond to
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>


To
"'RPG programming on the IBM i / System i'" <rpg400-l@xxxxxxxxxxxx>
cc

Subject
RE: Good places to use "The Cycle" in today's RPG was->Re: FW:
Niftiest thing(s) you have done in RPG ILE or /FREE






I do it the way you don't.

dow '1';
read file;
if eof;
leave;
endif;
processdata;
enddo;

That's MY opinion and I'm sticking to it. <g>


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.