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



James and others

I sorry if I offended anyone with number 3. I do the same thing and code
in the same principles as James descibes, I just never found a need to use
an Iter or Leave that I couldn't code for within the loop. Not saying
they are out there.


Jeff Davis
Programmer
Dental Network of America
2 Transam Plaza Drive, Suite 500
Oakbrook Terrace, IL. 60181
630.691.0336




"James Perkins" <jrperkinsjr@xxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
01/09/2009 01:54 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






Quote:
"3 Leave and Iters just show that the programmer didn't want or
have the time to properly figure out the loop termination points"

Wow! That's harsh. I use ITER A LOT. I feel I take plenty of time to
figure
out my termination. I'm not suggesting everyone must use it, but I do.

Generally I try to keep the main logic short and simple. I use
subprocudres
(or a service program) to represent complex logic.

Example:

// Read through a file and update only items that need to be changed
setll *start myFile;
dou (%eof(myFile));
read myFile myDS;
// Leave if EOF
if (%eof(myFile));
leave;
endif;

// Make sure I want this record
if (not isValid());
iter;
endif;

eval-corr myDSOutput = myDS;
myDSOutput.chguser = user;
myDSOutput.chgfld = newValue;
update myFiler myDSOutput;
enddo;

*inlr = *on;
return;

// Imagine the procedure header is here...
// Check to see if the record is in the change file
chain (myKey) chgFile change;
if (%found(chgFile));
return *off;
endif;

return *on;
// End Program


To me, this is very clean. Not each time you are looking at the program
you
care what makes the record valid. Or say you want to add logic to
invalidate
a record. Simply add the code do the isValid() procedure.

Again, this is just all opinion.

Regards,
James R. Perkins

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.