|
Ah, the great 'how to read a file' discussion. Nothing beats a classic. Here's my .02. RPG offers a very clean way to do this. Its called the cycle (ducking, running, hiding), but if you want to control it yourself you have to decide which is worse - data file access in two places (double the opportunities to screw something up under maintenance) or loop exit checking in two places (offends purists aesthetic sensibilities). Neither is 100% satisfactory. I would be surprised if either turned out to be significantly superior in performance. For clarity and maintenance, it is probably best to pick one as a shop standard and stick with it. Then everyone knows what to look out for. That said, I prefer: Setll key format; Dou %eof; Reade key format; If not %eof; do stuff; Endif; Enddo; Because it allows easy skipping of records and quitting: Setll key format; Dou %eor Reade key format; If not %eof; if don't want this record; iter; endif; if all done for some other reason; leave; endif; Endif; Enddo; Although this loop has one entrance and one exit, there are those who would say it is not structured unless it is re-written to have 25 endifs at the bottom. Pfuie.
As an Amazon Associate we earn from qualifying purchases.
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.