Too Many Open Files (was Re: The CLOSE command)

Kenneth Brody kenbrody at bestweb.net
Mon Feb 20 08:10:45 PST 2006


Quoting John Esak (Mon, 20 Feb 2006 10:00:05 -0500):
[...]
> Well, I understood what would happen and still did the following ...
> from years and decades ago. It has never bitten me. I knew both files
> would be open,  but it was and is easier to do somthing like this...
> howver, it *is* bad programming:
>
>      if:
>    then: lookup npio=npio k=ky i=A -nx
>      if: not npio
>    then: lookup npio=npio at hist k=ky i=A -nx
[...]
> It was always just easier to do it this way, and I've never needed to
> close the first file just because the lookup failed. I acknowledge that
> I'm doing some bad programming here though.
>
> I agree, now the dog can sleep forever.

Well, I'm not sure why you would call it "bad programming".

In this scenario, you have two other options, as I see it:

    1 - Close both lookups after you're done.  (ie: close the first
        if it fails, and close whichever is open at the end.)  But,
        given that this routine is probably called numerous times,
        you have to decide if the overhead of possibly having to
        open both files each time you come here is worth it.

    2 - Use different aliases for the lookups, and duplicate all of
        the code used to access the record.

I see no reason to duplicate the code simply to use different aliases,
and unless your resources are tight, the overhead of having to reopen
the files every time through may not be worth it.

--
KenBrody at BestWeb dot net        spamtrap: <g8ymh8uf001 at sneakemail.com>
http://www.hvcomputer.com
http://www.fileProPlus.com


More information about the Filepro-list mailing list