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



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.