You are here: Development Standards > Routines > General Routines > GENOPEN

# GENOPEN

GENOPEN is a general routine that interfaces to GENOPEN.PUB to OPEN and CLOSE data files. GENOPEN occupies lines 8300–8399 and should be merged into all programs that OPEN data files.

Variable | Description
F0 | File array index to store channel number. Valid numbers are 1–70 [actually 1 to NUM(STBL(“CHANNELS”))]. Use a negative array index to indicate that the file should be locked.
F$ | The name of the file to open
FILE[F0] | The channel of the OPENed file is stored in the file array
TASK | Determines the task GENOPEN.PUB is to perform. 0 = OPEN the file in F$ on the index array channel in F0 1 = Get the string template for the file in F$ 2 = OPEN the file in F$ on the index array channel in F0 and get the file’s string template 3 = Search for the file in F$ in the FILE[] array and return the channel index (if found) in F0 4 = CLOSE the data file on index array channel F0 5 = Search for the file in F$ in the FILE[] array and return the channel index (if found) in F0, or open the file if the file was not found and return the FILE[] array index in F0 (if F0 is negative on return, the file was opened in GENOPEN.PUB) 6 = Search for the file in F$ in the FILE[] array and return the channel index (if found) in F0, or open the file and retrieve the string template if the file was not found 7 = Search for an open index in the FILE[] array and open the file in F$ on that index. 8 = Search for an open index in the FILE[] array, open the file in F$ on that index, and return the file's string template. 9 = Check if file in F$ exists. Return -9 in TASK if file is not found. 10 = Unlock a previously locked file. 11 = Lock a previously unlocked file. 12 = Open OSMN file and return the string template.
TPL$ | GENOPEN.PUB returns the string template retrieved (if any)
MSG$ | An error message is returned if the operation is unsuccessful
Y$ | GENOPEN.PUB and the CALLing program share the current command, in case the user aborts processing
GENOPEN$ | String template used by GENOPEN.PUB

Exit Points | Explanation
RETURN | GENOPEN returns after opening the file.
ERR=GENERROR | Errors branch to GENERROR. If possible, the user can retry the open; otherwise, he is forced to exit.

This chart breaks down the GENOPEN$ template:

Field | Description
CRYP:N(1*) | Set to 1 if file to be opened is an encrypyted file.
RET:C(1*) | Set to "U" if a file is not available to be locked or unlocked.
METHOD:N(1*) | Not used