Click or drag to resize

Cdx Function

X#
Returns the names of the open compound index (.cdx) file that has the specified index position number.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.21
Syntax
 FUNCTION Cdx(
	nIndexNumber,
	uArea
) AS USUAL CLIPPER
Request Example View Source

Parameters

nIndexNumber (Optional)
Type: Usual
The tables in Remarks apply to a table with a structural compound index and one or more compound indexes
uArea (Optional)
Type: Usual
Specifies the work area number or alias of a table whose open compound index file names you want CDX( ) to return.
If you omit this, names of compound index files are returned for the table in the currently selected work area.

Return Value

Type: Usual
Character
Remarks
nIndexNumberDescription
1Returns the name of the structural index file (which is always the same as the name of the table).
2Returns the first compound index file name specified in the Index clause of Use or in Set Index.
3 Returns the second compound index file name, if any, and so on.
Greater than the number of open .cdx files Returns the empty string.
The following apply to a table with no structural compound index and one or more compound indexes:
nIndexNumberDescription
1
2Returns the first compound index file name specified in the Index clause of Use or in Set Index.
Greater than the number of open .cdx files Returns the empty string.
The CDX( ) function is identical to the MDX( ) function.
A .cdx (compound) index consists of one physical file containing many index tags. Each index tag is an index order reference for the associated table.
There are two types of .cdx files: standard compound index (.cdx) and structural .cdx. A standard compound index (.cdx) may have a different name from its associated table and can reside in a different directory from its associated table. A table can have multiple compound index files. You open a compound index with the Index clause of Use or with Set Index.
A structural .cdx must have the same name as its associated table and reside in the same directory. A table can have only one structural index file. Structural .cdx files are automatically opened and updated when the associated table is opened with Use.
CDX( ) ignores any .idx (Microsoft FoxBASE+ and FoxPro 1.0 compatible index) files specified in Use or Set Index.
Use TAG( ) to return individual tag names contained in a .cdx, and NDX( ) to return the name of open .idx files.
When Set FullPath is ON, CDX( ) returns the path and name of the .cdx. When Set FullPath is OFF, CDX( ) returns the drive and name of the .cdx.
Examples
X#
 1Close Databases
 2Open Database (HOME(2) + 'data\testdata')
 3Use customer     // Open customer table
 4Clear
 5For nCount = 1 TO TAGCOUNT( )
 6IF !EMPTY(TAG(nCount))  // Checks for tags in the index
 7? CDX(nCount)     // Display structural index names
 8ELSE
 9EXIT  // Exit the loop when no more tags are found
10ENDIF
11ENDFor
See Also