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






"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
=======================================================
The opinions expressed in this communication are my own and do not
necessarily reflect those of my employer.


______________________________________________________________________
This message may contain confidential information which may also be legally 
privileged and is intended only for the use of the parties to whom it is 
addressed. If you are not an intended recipient you are hereby notified that 
any disclosure, copying, distribution or use of any information in this e-mail 
is strictly prohibited. If you receive this message in error please notify the 
sender by return e-mail and then destroy it. Further, we make every endeavour 
to keep our network free from viruses. However, you do need to verify that this 
e-mail and any attachments are free of viruses as we can take no responsibility 
for any computer viruses which might be transferred by way of this e-mail. All 
information and attachments remain the property of Stolt Offshore Group and 
should be held as confidential.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.