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



On Mon, 2010-03-01 at 08:53 -0500, rob@xxxxxxxxx wrote:

Besides, I find this more readable
setll myfile;
dow ReadMyfile();

I suggest that it is a virtue to have logically related operations close
together in the source code. Thus, either to promote the read operation
up here or to use two functions myFile_setll() and myFile_read().

// process row
...
if recid<>'A';
iter;
endif;
EndDo;

Than
setll myfile;
read myfile; // priming read
dow not %eof(myfile);
// process row
if recid<>'A';
iter;
endif;
read myfile;
EndDo;

That, and the second example has an infinite loop while the first doesn't.

And that is just the current problem. Hereafter you have to maintain
the two occurrences of "read myfile;" in sync. I almost always deem it
worthwhile to increase the bulk of code ...

setll myfile;
dow 0 = 0; // Yes, this is ugly.
read myfile; // Down to one of these now.
if %eof(myfile); // These three lines were
leave; // part of the dow/enddo
endif; // structure.

// process row

And, if you want to move the recid <>'A' logic into ReadMyfile you could.

Or, if you have just one read operation at the top of the loop, then you
can express that filter in positive terms ...

if recid = 'A';
// do something
endif;

Here we are closing in on what I see as a central tension, the
difficulty of guessing in advance what the reader is really interested
in and what the reader would rather see abstracted away.

My possibly ideosyncratic opinion is that the selection is often more
interesting than the details of "// process row" or "// do something".
Or, perhaps I should say that that the selection tells the reader more
about what to expect from "// process row" and "// do something" than
vice versa. These are not really the same question, are they?

Cheers,
Terry.



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.