Show/Hide Toolbars


NoteThis command is defined in a header file and will be preprocessed by the X# preprocessor to a function call. If you disable the standard header (-nostddefs) files then this command will not be available. If you tell the compiler to use a different standard header file (-stddef ) then this command may also be not available


Open one or more index files and add their orders to the order list in the current work area.


SET INDEX TO [<xcIndexFileList> [ADDITIVE]]


TO <xcIndexFileList>The names of the index files to open, including an optional drive, directory, and extension for each.  See SetDefault() and SetPath() for file searching and creation rules.  The default extension is determined by the RDD and can be obtained using DBOrderInfo(DBOI_INDEXEXT).  
If a file in the list does not exist, a runtime error is raised.  If it exists, this command attempts to open the file in the same mode as the corresponding database file.  If access is denied because, for example, another process is using the file and this one is asking for exclusive use, NetErr() is set to TRUE.  Otherwise, the file open is successful, the command proceeds to the next file in the list.
Concurrency conflicts with index files are rare since they should be used with only one database file.  If a concurrency problem arises, it will normally be when you attempt to open the database file.  
SET INDEX TO with no file name clears the current order list.


ADDITIVEAdds the orders from the indicated index files to the current order list, leaving the controlling order intact.  If not specified, a new order list is constructed from the indicated index files, replacing the current order list.


If no order list exists for the work area or if SET INDEX is replacing the current order list, the type of RDD determines whether or not the controlling order is set.  For RDDs that support only single-order index files (such as DBFNTX), the controlling order is set to the order in the specified index file.  For RDDs that support multi-order index files (such as DBFMDX), you usually need to set the controlling order explicitly (using, for example, SET ORDER or DbSetOrder() otherwise, the data file may be processed in natural order even though there is an order list in effect.


After the new index files are opened, the work area is positioned to the first logical record in the controlling order and all subsequent database operations process the records using the controlling order.


During database processing, all orders in the order list are updated whenever a key value is added or changed, respecting any for condition or unique flag in the order.  To change the controlling order without affecting the current order list, use SET ORDER or DBSetOrder().  To find out information about a particular order or index file, use DBOrderInfo().


SET INDEX TO when specified with an index file list is functionally equivalent to using several DBSetIndex() function calls.  If no ADDITIVE clause is specified, the command calls DBClearFilter() first.  


This example opens a database and several associated index files:


USE sales NEW
SET INDEX TO sales, sales1, sales2


The next example opens an index file without closing any that are already open:





See Also

CLOSE, DBClearIndex(),DbOrderInfo(), DBSetIndex(), DBSetOrder(),INDEX, REINDEX, SET ORDER, SetDefault(), SetPath() USE