|
Allow me to vote for this one too. Of course with variations. It has actually helped me "keep the loop-logic in one place" because of all the "iter" cases you want to do sometimes, and the breaking logic that somebody else referred to. Of course some of those convoluted reports really cry out for primary/secondary looping. Hah! Mr RPG did "Group by" [MR] long before SQL was even a glint in its father's eye...<g> - Alan ----- Original Message ----- From: "G Armour" <garmour400m@xxxxxxxxx> To: "Midrange Systems Technical Discussion" <midrange-l@xxxxxxxxxxxx> Sent: Friday, November 21, 2003 12:41 PM Subject: Re: Two reade loops: which one preferred ? | Thank goodness for the voice of reason! <g> | | Though I wonder, Henrik, why would this cost a few more cycles? I can't | see logically how one could eat more cycles doing it this way. But, of | course, this is not a paramount consideration. | | GA | | --- Henrik Krebs <hkrebs@xxxxxxxxx> wrote: | > A reason why style #1 might be preferred is that 'Do forever' is | > misinformational unless you have a veeery large file. | > | > But I actually use style #3: | > ----- Style #3 ------------------------------------------- | > | > mykey setll record | > dou %eof | > mykey reade record | > if not %eof | > ... process ... | > endif | > enddo | > | > because I think it's cleaner. | > Why? | > 1. First of all: Read can return either a) a record or b) an eof flag, | > and we (you) only want 'process' in case 'record' | > You could also inside the loop have coded for both situations (select | > or if..else) | > 2. It's clean: only a single 'read' to control a 'read-loop'. Both | > style #1 and #2 has two or three different routes through the code: zero | > records, a record read and no more records | > 3. No 'Do forever' that definately is not 'forever' | > 4. Same construction (the fewer the better) for 'read entire file' | > (except the missing setll of cause). | > | > It might mean a few more cykles, but they are cheaper than programmer | > time | > | > Henrik | | | | __________________________________ | Do you Yahoo!? | Free Pop-Up Blocker - Get it now | http://companion.yahoo.com/ | _______________________________________________ | This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list | To post a message email: MIDRANGE-L@xxxxxxxxxxxx | To subscribe, unsubscribe, or change list options, | visit: http://lists.midrange.com/mailman/listinfo/midrange-l | or email: MIDRANGE-L-request@xxxxxxxxxxxx | Before posting, please take a moment to review the archives | at http://archive.midrange.com/midrange-l. |
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.