Hi John,

As you surmised, this is not a new trick. Here is my version:

SUBROUTINE OPEN.FILE.SUB(FILENAME,FILEVAR,ERROR)
* open filename to filevar, keep opened files in named common
* 01-20-01 asb
COMMON /OPEN.FILE.SUB/ FILENAMES,FILEVARS(1000)
IF ASSIGNED(FILENAMES) ELSE
  FILENAMES = ""
END
ERROR = ""
LOCATE(FILENAME,FILENAMES;POS) THEN
  FILEVAR = FILEVARS(POS)
END ELSE
  OPEN FILENAME TO FILEVAR THEN
    IF POS LE 1000 THEN
      FILENAMES<POS> = FILENAME
      FILEVARS(POS)  = FILEVAR
    END
  END ELSE
    FILEVAR = ""
    ERROR = 1
    CRT @(0):"ERROR! can't open ":FILENAME:@(-4)
  END
END
RETURN

In use, you CALL OPEN.FILE.SUB("MYFILE",FILEVAR,ERR) ; IF ERR THEN ....

Interestingly, on D3 this does not seem to have much benefit, where the OPEN
function seems faster than the LOCATE.

/Scott Ballinger
Pareto Corporation
Edmonds WA USA
206 713 6006

On Jan 24, 2008 6:56 AM, john reid <[EMAIL PROTECTED]> wrote:

> I just saw this today, and although i am certain that everyone must
> know it already, i am including it.
> For itypes that call subroutines, where the subroutines open lots of
> files, put a named common in the subroutine that contains what amounts
> to dimensioned arrays that hold the file vars. Put a switch in so that
> the files are opened only once.
> Anecdotally, this appears to work more efficiently than not having the
> common. If there are reasons why this is ill-advised, I'd like to see
> that as well.
> thanks.
> John
> COMMON /SETUP.STUFF/MY.FILES(15),FIRST.IN.SWITCH
> --
> john
> -------
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to