SUBROUTINE OPEN.FILE(CONTROL,DICT,FILENAME,FILE.VARIABLE,ERROR)
****
*
*     OPEN.FILE
*
*     This program will dynamically open and maintain file variables.
* It suppresses the need to reopen files.  The arguements are defined as
* follows:
*
*     CONTROL accept two keywords to affect how this subroutine is used.
* RESET   - Causes the COMMON block to be reset, all existing file
*           variables are ignored.
* FORCE   - Forces an OPEN statement to be executed irregardless of wether
*           the file has already been previously opened.
*
*     DICT is used to idicate that the dictionary portion of a file is to
* be opened.
*
*     FILENAME is the actual file to be opened, as defined in the user's
* vocabulary file.
*
*     FILE.VARIABLE is the file variable that the file in question was
* opened to.
*
*     ERROR, if any error condition was raised during this subroutine, an
* error message will be loaded in to this argument.
*
****
*                           R E V I S I O N   L O G
* PR#     WHEN     WHO        WHY
* ======= ======== ========== ===========================================
* 001     16JULY86 MCLAUGHLIN INITIAL CODING
*
*
****

     TRUE = 1
     FALSE = 0
     OTHERS = TRUE

     MAX = 1000
     COMMON /FILES/ FILENAMES, SIZE, FILE.VARIABLES(MAX)

     IF CONTROL EQ 'RESET' THEN
        FILENAMES = ''
        SIZE = 0
        RETURN
     END

     SEEK = DICT:'>':FILENAME
     LOCATE SEEK IN FILENAMES<1> SETTING PTR ELSE
        OPEN DICT,FILENAME TO FILE.VARIABLE ELSE
           ERROR = 'Unable to open ':FILENAME:' file.'
           RETURN
        END

        IF SIZE GE MAX THEN
           ERROR = 'Unable to open file, to open would exceed present limits of 1000 files.'
           RETURN
        END

        SIZE += 1
        FILENAMES<SIZE> = SEEK
        FILE.VARIABLES(SIZE) = FILE.VARIABLE
        ERROR = ''
        RETURN
     END

     IF CONTROL EQ 'FORCE' THEN
        OPEN DICT,FILENAME TO FILE.VARIABLE ELSE
           ERROR = 'Unable to open ':FILENAME:' file.'
           RETURN
        END
        FILE.VARIABLES(PTR) = FILE.VARIABLE
        ERROR = ''
        RETURN
     END

     FILE.VARIABLE = FILE.VARIABLES(PTR)
     ERROR = ''
     RETURN
  END
