table.INDEX_OPEN Function
Syntax
Arguments
- P
An object pointer that references the first tag in the specified index file. You can get an object reference to any of the other tags in the index file using the <TBL>.INDEX_GET() method.
- index_name
The name of an index file.
Description
Open an index file for the database.
Discussion
The .INDEX_OPEN() method opens an existing index file, called Index_Filename, attaching it to an open table referenced by its object pointer, . By default, a table's production index (an index file with the same name as the table file) is automatically opened and attached when the table is opened. In addition to the production index file, you can explicitly attach an index file using the .INDEX_OPEN() method. If more than one index file is opened for a particular table, all the index files are maintained as records are added or changed.
Example
This script opens the Customer_temp.cdx index file and attaches it to the current table. The index file is updated to be sure any records that may have been added or changed while the index file was not open are included in the index.
dim tbl as P tbl = table.current() idx = tbl.index_open(a_db_current_path + "customer_temp.cdx") 'Index update requires exclusive access to the table. 'If you do not have exclusive access, an error is generated. ON ERROR GOTO error_handler idx.update() end error_handler: ui_msg_box("Error","Index was not updated. Cannot get exclusive access to table",UI_STOP_SYMBOL) RESUME NEXT
See Also