Creates a table access variable (a file handle).


Open ["DICT",] expression To table_var Then | Else statements


The Open statement has the following parameters.

expressionDesignates the native table that is to be opened. To open the dictionary, use DICT as the first part of the table name (example: "DICT.CUSTOMERS"); and to open the data portion of the table, use only the table name (example: "CUSTOMERS"). Use separate Open statements to open the DICT and data portions of each table.
table_varAfter a successful Open operation, table_var contains information about the table. From that point on, refer to the table with table_var, not with the actual table name.
ThenThe statement(s) following Then are executed if a table is opened successfully.
ElseThe statement(s) following Else are executed if the table cannot be opened. The Status() function indicates the severity of the error, and the system variable @FILE_ERROR contains detail about the nature of the error.

You must Open a table before attempting to Read or Write rows from/to that table. As long as a table has been opened once, it does not need to be opened again each time you want to Read or Write to it.

Each table must be opened with a separate Open statement. Any number of tables may be opened at any point in the program.

Tables opened with the Open command need not and cannot be closed.

See also

Index.Open subroutineAttach_Table


/* The following program demonstrates file opening and subsequent processing. */
table = "CAR_PARTS"
Open table To tablevar Then
  Open "DICT", table To @DICT Else null
End Else
  * error processing:  cannot open table
Select tablevar
Done = 0
Printer On
  ReadNext @ID Else done = 1
Until done
  Read @RECORD From tablevar, @ID Then
    report = {PART_NAME}:" ":{PART_TYPE}:" ":{PART_NO}
    Print report
Printer Off
  • No labels