SUBROUTINE OPEN(DICT, FILENAME, FILE, ERROR)
LastUpdated... = "Rev: 11:42 15Jul1999 andrew 1 /roi/andrew/BP/OPEN"
* Common block storage of file handles.
***
* Copyright (C) 2000, Andrew McLaughlin.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
* or http://www.fsf.org/copyleft/gpl.html
*
*   Enjoy, Andrew McLaughlin - andrew@mclaughlin.orange.ca.us
*** 
*    Program to open and retain handle to files used during a user's
* login session.
***
* Revision Log
* Proj Who.. When.... Why................................................
*      Andrew May1986 Initial coding.
* NONE u2443 12-14-94 Port to UniData/Manage-2000.                       
*     andrew 15Jul1999 Added FATAL references to all error messages for better 
*                     communication to call callers.
*
***
 
ERROR = ''
COMMON /FILES/FILENAMES, FILES(1000), LAST.FILE, USAGE
IF LAST.FILE EQ 0 THEN
   FILENAMES = ''
   MAT FILES = ''
END

IF LAST.FILE EQ 1000 THEN
   ERROR<-1> = "FATAL: Unable to open file, storage area is full, 1000 entries. (OPEN)"
   RETURN
END

COMPOSITE = @WHO:'!':DICT:'!':FILENAME
LOCATE COMPOSITE IN FILENAMES<1> SETTING POS ELSE
   OPEN DICT,FILENAME TO FILE ELSE
      ERROR<-1> = "FATAL: Unable to open the ":TRIM(DICT:" ":FILENAME):" file."
      RETURN
   END
   LAST.FILE += 1
   FILENAMES<LAST.FILE> = COMPOSITE
   FILES(LAST.FILE) = FILE
   USAGE<POS> = 1
   RETURN
END
FILE = FILES(POS)
USAGE<POS> = USAGE<POS> + 1
RETURN
END
