Condividi tramite


SET INDEX Command

Opens one or more index files for use with the current table.

SET INDEX TO [IndexFileList | ? ] [ORDER nIndexNumber
 | IDXIndexFileName | [TAG] TagName [OF CDXFileName] [ASCENDING
 | DESCENDING]] [ADDITIVE]

Parameters

  • IndexFileList
    Specifies one or more index files to open. Use commas to separate multiple index files in the list. The index file list can contain any combination of .idx and .cdx index file names; you don't have to include the file name extensions unless another .idx or .cdx file exists with the same name.

    The first index file in the index file list becomes the controlling index file, which controls how records are accessed and displayed. The records are displayed and accessed in physical record order if the first index file is a .cdx file and SET ORDER TO TAG has not been issued.

  • ?
    Displays the Open dialog box from which you can open a single .idx file.

  • ORDER nIndexNumber
    Specifies a controlling index file or tag. The numeric expression nIndexNumber specifies the index files as they appear in the index file list.

    .Idx files are numbered first in the order in which they appear in the index file list. Tags in the structural .cdx file (if one exists) are numbered in the order in which the tags were created. Finally, tags in any independent .cdx files are numbered in the order in which they were created. See SET ORDER for a further discussion of the numbering of index files and tags.

    If nIndexNumber is 0, records in the table are displayed and accessed in physical record order, but the index files remain open. ORDER 0 enables you to update open index files while accessing records in physical order. ORDER with no additional arguments is identical to ORDER 0.

    Visual FoxPro generates an error message if nIndexNumber is greater than the number of .idx files and .cdx file tags.

  • ORDER IDXIndexFileName
    Specifies an .idx file as the controlling index file.

  • ORDER [TAG] TagName [OF CDXFileName]
    Specifies a tag (TagName) of a .cdx file to be the controlling tag. The tag name can be from the structural .cdx file or any open independent .cdx file.

    If tags with the same name exist in open independent .cdx files, use OF CDXFileName to specify the .cdx file the tag is in.

  • ASCENDING | DESCENDING
    Specifies whether table records are displayed and accessed in ascending or descending order. The index files or tags aren't changed in any way; only the order in which the records are displayed and accessed is changed. Include the ASCENDING or DESCENDING clause immediately after the ORDER clause.

  • ADDITIVE
    Specifies that previously opened index files, except for a structural compound index, are left open when you issue SET INDEX to open an additional index file or files for a table. Without ADDITIVE, the previously opened files would be closed.

Remarks

Records in a table that has an index file or files open can be displayed and accessed in an order determined by one of the index files. Both single index (.idx) and compound (.cdx) index files can be opened with SET INDEX. If a table has a structural .cdx file, the file is opened automatically when the table is opened.

Only one .idx file (the controlling index file) or tag from a .cdx file (the controlling tag) controls the order in which records in the table are displayed or accessed. Certain commands (SEEK, for example) use the controlling index file or tag to search for records.

Issuing SET INDEX TO without additional arguments closes all open index files (except a structural .cdx file) in the current work area.

See Also

CLOSE INDEXES | INDEX | SET ORDER | USE