OPEN


The OPEN statement is used to open a file or device to a descriptor variable within jBC.

 

COMMAND SYNTAX

OPEN {expression1,}expression2 TO {variable} {SETTING setvar} THEN|ELSE statements

 

SYNTAX ELEMENTS

The combination of expression1 and expression2 should evaluate to a valid file name of a file type that has been installed into the jBASE system. If the file has a dictionary section and this is to be opened by the statement then this may be specified by the literal string "DICT" being specified in expression1. If specified, the variable will be used to hold the descriptor for the file. It should then be to access the file using READ and WRITE. If no file descriptor variable is supplied, then the file will be opened to the default file descriptor.

Specific data sections of a multi level file may specified by separating the section name from the file name by a "," char in expression2.

If the OPEN statement fails it will execute any statements associated with an ELSE clause. If the OPEN is successful it will execute any statements associated with a THEN clause. Note that the syntax requires either one or both of the THEN and ELSE clauses.

If the SETTING clause is specified and the open fails, setvar will be set to one of the following values:

Incremental File Errors

128 No such file or directory
4096 Network error
24576 Permission denied
32768 Physical I/O error or unknown error

 

NOTES

The OPEN statement uses the environment variable JEDIFILEPATH to search for the file named. If this is not defined then the current working directory is looked in followed by the home directory of the current process. See the documentation on environment variables for more details.

The file that is the subject of the OPEN statement can be of any type known to the jBASE system. Its type will be determined and correctly opened transparently to the application, which need not be aware of the file type.

There is no limit to the number of files that may be opened by a jBC program.

 

EXAMPLES

OPEN "DICT", "CUSTOMERS" TO F.Dict.Customers ELSE
     ABORT 201, "DICT CUSTOMERS"
END

opens the dictionary section of file CUSTOMERS to its own file descriptor F.Dict.Customers.

 

OPEN "CUSTOMERS" ELSE ABORT 201, "CUSTOMERS"

opens the CUSTOMERS file to the default file variable.


jBC