tldm-universe/Ardent/UV/APP.PROGS/CLOSE.FILE.B

101 lines
3.5 KiB
Plaintext
Raw Permalink Normal View History

2024-09-09 21:51:08 +00:00
******************************************************************************
*
* CLOSE.FILE.B - Close file opened by OPEN.FILE.B
* (catalog name CLOSE$UV$FILE)
*
* Module %M% Version %I% Date %H%
*
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
* This is unpublished proprietary source code of Ardent Software Inc.
* The copyright notice above does not evidence any actual or intended
* publication of such source code.
*
*******************************************************************************
*
* Maintenence log - insert most recent change descriptions at top
*
* Date.... GTAR# WHO Description........................................
* 10/14/98 23801 SAP Change copyrights.
* 11/04/92 10327 WLC Updated incorrect comments.
* 10/12/92 10327 WLC Initial release.
*******************************************************************************
*
* This subroutine replaces a standard UniVerse BASIC CLOSE
* statement. It checks a table to see if the given file
* has previously been opened. If not, the file is clsoed.
* If it was, close is done, and related labelled common entries
* are removed.
*
SUBROUTINE CLOSE$UV$FILE(FILE.VAL, VAR.STAMP)
*
* FILE.VAL : file to be closed
*
* VAR.STAMP : string containing variable name with _# appended
* # is unique for each source program.
* (See OPEN.UNIQUE file in /.uvhome)
*
*
* Equates
*
* TABLE.MAX: This is the MAXIMUM number of entries that ONE
* user can make. Basically, the maximum number
* of files that can be "held" open.
*
$INCLUDE UNIVERSE.INCLUDE OPEN.TOOLS.H
*
$OPTIONS PICK
* Declare named common
*
COMMON /UV$open$files/ FILE$VARS(TABLE.MAX),FILE$TABLE(5),curr$UV$ACCOUNT
*
* FILE$VARS : contains actual filevars that are returned
* FILE$TABLE : 5 elements
* element 1 : list of opened file names ascending left (multi valued)
* element 2 : pointer into file$vars array (multi valued)
* element 3 : current number of open files (single value)
* element 4 : file open requests (multi valued)
* element 5 : variable stamp - unique identifier for the variable name
* used in open call. (multi valued)
*
* curr$UV$ACCOUNT : the name of the account in which these files
* were opened.
*
*
* Equates
*
EQU FILES.NOW.OPENED TO FILE$TABLE(1) ;* list of file names
EQU TABLE.POINTER TO FILE$TABLE(2) ;* list of pointers to FILE$VARS
EQU TABLE.COUNTER TO FILE$TABLE(3) ;* current # of FILE$VARS
EQU OPEN.REQUESTS TO FILE$TABLE(4) ;* list of # of open requests
EQU VARIABLE.LIST TO FILE$TABLE(5) ;* list of variable stamps
EQU NO TO 0
EQU YES TO 1
*
* Find the variable stamp in the list to determine which FILE$VAR entry to close
*
locate VAR.STAMP in VARIABLE.LIST setting field.loc else field.loc=0
if field.loc then
CLOSE FILE$VARS(TABLE.POINTER<field.loc>)
TABLE.POINTER=delete(TABLE.POINTER,field.loc)
FILES.NOW.OPENED=delete(FILES.NOW.OPENED,field.loc)
OPEN.REQUESTS=delete(OPEN.REQUESTS,field.loc)
VARIABLE.LIST=delete(VARIABLE.LIST,field.loc)
end else
* We never opened it, close it anyway!
CLOSE FILE.VAL
end
*
* If this was the entry on the end, then we can re-use it.
*
if TABLE.POINTER<field.loc> = TABLE.COUNTER then TABLE.COUNTER-=1
*
* Return to calling program
*
return
*
* End of subroutine
*
END