Within the uv account there is a file called APP.PROGS which contains a number of interesting routines. The file description is – File – Used to store unsupported programs and user-contributed programs. Mmmmm…

There are 351 routines (10.2.0 pe) within the file and some are quite interesting.

As I have done a lot of work with SB+, I found that the cached file opens do make a significant difference in speed when used (SB.FILE.VAR.S etc.).

Within the APP.PROGS file there are 5 routines which can be used to implement file open caching within your own programmes..

They are:

Routines for the UV Open Tools
Routine Name Calling Name and syntax Description
OPEN.FILE.B CALL *OPEN$UV$FILE(DICT.VAL, DATA.VAL, FILE.VAL, VAR.STAMP) Open the file and cache file variable
CLOSE.FILE.B CALL *CLOSE$UV$FILE(FILE.VAR, VAR.STAMP) Close the file
RLS.FILE.B CALL *RELEASE$UV$FILE(UNIQUE.ID)
EXAM.COMMON.B RUN APP.PROGS EXAM.COMMON.B Display on the screen the files opened and cached
OPEN.INIT.B RUN APP.PROGS OPEN.INIT.B Run from the uv ACCOUNT as a super user (root) to create the file and initialize it.

There is also the OPEN.TOOLS.H in the UNIVERSE.INCLUDE file.

The COMMON UV$open$files is used to track the open and close of each file. It contains a dimensioned array of file names and file variables.

The routines have an INCLUDE for the OPEN.TOOLS.H file from the UNIVERSE.INCLUDE file and are compiled with the $OPTIONS PICK.

The OPEN.UNIQUE file within the uv account tracks the files within all accounts as they are opened and closed.

All the routines have documentation and should be read to understand usage and limitations.

Example


VAR.STAMP = "TESTPROG"
*
CALL *OPEN$UV$FILE("", "CUSTOMERS", CUST.FV, VAR.STAMP)
IF @USER.RETURN.CODE EQ 0 THEN
*
* ERROR
...
END
*
READ CUST.REC FROM CUST.FV THEN
*
...
END
*
CALL *CLOSE$UV$FILE(CUST.FV, VAR.STAMP)
...

Points of Interest

The use of the user return code (@USER.RETURN.CODE) is interesting. This system variable has the same functionality as the STATUS() function except your own routines can set a return/error code to pass back to the calling routine. Rather useful, I would have though, specially if you like to use functions.

The official info (not much) can be found from the online help by:


HELP BASIC @variables

or from the UniVerse manuals.