Order(), Set Order, Set("Order"), Set Index, Set("Index"), Sys(21), Sys(22)
These commands and functions all relate to putting an index in control and finding out which one is currently in control. ORDER() and SET ORDER are the most up-to-date ways to do this stuff. SET ORDER lets you specify a tag or stand-alone index to control the table. ORDER() lets you find out which one it is. SET INDEX lets you open stand-alone indexes and non-structural compound indexes, as well as setting one of them in control. SYS(21) and SYS(22) are antique ways to find out which index is in charge. Don't use them because, like all the SYS() functions, their names give you no clue what they're about.When tables or indexes are opened, each stand-alone index and tag is assigned a number, based on its position. Several of these commands use that number to refer to a particular index or tag. See CANDIDATE() for details on this numbering. Like work area numbers, we recommend you avoid these numbers whenever possible and refer to indexes by name.
Usage |
cCurrentOrder = ORDER( [ cAlias | nWorkArea [ , nIncludePath ] ] ) |
Parameter |
Value |
Meaning |
cAlias |
Character |
Return the current order in the work area whose alias is cAlias. |
Omitted |
If nWorkArea is also omitted, returns information for the current work area. |
|
nWorkArea |
Numeric |
Return the current order for work area nWorkArea. |
Omitted |
If cAlias is also omitted, return information for the current work area. |
|
nIncludePath |
Numeric |
Include the full path to the index file. |
Omitted |
Return just the index or tag name. |
|
cCurrentOrder |
Character |
The name of the current index or tag. If nIncludePath is specified, includes the full path to the index file. For tags with nIncludePath, returns the name of the compound index file with its path rather than the tag. |
Usage |
SET ORDER TO [ nIndexNumber | IndexFileName | [ TAG ] TagName [ OF CompoundIndexFile ] [ IN cAlias | nWorkArea ] [ ASCENDING | DESCENDING ] ] SET INDEX TO [ IndexFileList | ? [ ORDER nIndexNumber | IndexFileName | [ TAG ] TagName [ OF CompoundIndexFile ] [ ASCENDING | DESCENDING ] [ ADDITIVE ] ] |
Parameter |
Value |
Meaning |
nIndexNumber |
Numeric |
The number for the index to put in charge. |
IndexFileName |
Name |
The name of a stand-alone index to put in charge. |
TagName |
Name |
The name of a compound index tag to put in charge. |
CompoundIndexFile |
Name |
The name of the compound index file containing the specified tag. Can be omitted if the tag name is unique. |
cAlias |
Character |
Set the current order in the work area whose alias is cAlias. |
Omitted |
If nWorkArea is also omitted, set order for the current work area. |
|
nWorkArea |
Numeric |
Set the current order for work area nWorkArea. |
Omitted |
If cAlias is also omitted, set order for the current work area. |
|
IndexFileList |
List of Names |
A list of index files to open. |
The other confusing thing is that the direction you create the tag matters only when you first open the table any given time. Once you SET ORDER TO that tag once, FoxPro remembers the last direction you used that tag in. If you omit ASCENDING and DESCENDING on a subsequent SET ORDER, you get the orientation you used last. (If you omit them initially, you get the creation direction for that tag.) This effect continues until you close and reopen the table. |
Usage |
cCurrentOrder = SET( "ORDER" ) cIndexList = SET( "INDEX" ) |
Usage |
nTagNumber = SYS( 21 [, nWorkArea ] ) cTagName = SYS( 22 [, nWorkArea ] ) |
Example |
USE Customer SET ORDER TO Company_Na ? ORDER() && Returns "COMPANY_NA" ? ORDER("Customer", 1) && Returns something like * "C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO\ * SAMPLES\TASTRADE\DATA\CUSTOMER.CDX" ? SET("ORDER") && Returns something like * "TAG COMPANY_NA OF C:\PROGRAM FILES\MICROSOFT VISUAL * FOXPRO\SAMPLES\TASTRADE\DATA\CUSTOMER.CDX" ? SYS(21) && Returns 1 ? SYS(22) && Returns "COMPANY_NA" ? SET("INDEX") && Returns something like: * " c:\program files\microsoft visual * foxpro\samples\tastrade\data\customer.cdx ORDER TAG * company_na OF c:\program files\microsoft visual * foxpro\samples\tastrade\data\customer.cdx" |
See Also |