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

John Esak john at valar.com
Fri Feb 17 14:46:51 PST 2006


>
> That works fine unless you have multiple lookups that
> re-use the same alias.  For example:
>
> lookup fil = file1 k=ky i=a -nx
> lookup fil = file2 k=ky i=a -nx
> lookup fil = file3 k=ky i=a -nx
> close fil
>
> The above code only closes the open files from file3.
> I would like an option to close all of the open files
> from lookups.
>
> Jeff Harrison

Please don't take offense. (You always do, though... hopefully not this
time) The above snippet of code is simply bad programming. Think about it.
You open one lookup with an alias, than another lookup with the same alias
and don't *close* the first lookup. What do you expect? It is certainly
clear that you can not have access to the first lookup if you use the same
alias to the second lookup and so on... so, why not close any lookup for a
particular alias before you re-use that alias. There is nothing needed to
help you do this. Using "close alias" before a subsequent use of that alias
is not only painless, it is good programming sense.

As to this, should you want to be even more precise about open lookups, (in
many instances this is not very critical), you need to close lookups that
failed as well as those that don't.

  then: lookup alias=somfile k=(somekey) i=(someindex) -nx
    if: not alias
  then: return

is *not* going to close this lookup for you.

  then: lookup alias=somfile k=(somekey) i=(someindex) -nx
    if: not alias
  then: close  alias;  return

is the only proper way to do this.  However, I don't usually take the
trouble to do this myself. Unless, the alias is going to be used again.
Having lots of open files is not a problem for filePro, they get closed when
they should be by clerk or report as they should be. So, unless it is
something like your example, or Howie's, the problem will probably never
manifest in any way.

--
John Esak
(570) 384-2444

Author of:
The filePro Survivor Series
Complete Video Training For filePro On CD
See samples at: www.valar.com




More information about the Filepro-list mailing list