|
dkahn@xxxxxxxxxxxxxxxxx wrote:
"Jeff Crosby" <jlcrosby@xxxxxxxxxxxxxxxx> wrote:So do this: Dou %eof(myfile); Read myfile; If %eof(myfile); Leave; Endif; If itactv = 'N'; Iter; Endif; // process Enddo;This works of course, but I still have a minor quibble with it. The only way out of the loop is via the Leave operation, so why code %eof as the end condition on the Do? One very good answer would be that it documents the condition that causes processing to break out of the loop. However, it looks like something that ought itself to cause the loop to end, but it actually doesn't. Whenever I see this construction I always find myself looking twice at the code to see if I've missed something. If the Leave is the only way out of the loop I would prefer to see the until condition coded explicitly as an impossible one, so it would read something like: dou '0'; // Do forever Read myfile; If %eof(myfile); Leave; Endif; If itactv = 'N'; Iter; Endif; // process Enddo; I know many people will think this is less clear than Jeff's code, but I think it's slightly more correct. To me <Dou %eof(myfile)> implies that eventually processing could reach this point with the %eof condition true. <Dou '0'> on the other hand (ugly though it is) tells me explicitly that there needs to be another way of breaking out of the loop and highlights the significance of the Leave as the only way of doing so. -- Dave... _________ ,___o __________ _\ <;_ http://www.audax.uk.net ___________ (_)/ (_) http://www.twickenhamcc.co.uk =======================================================
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.