IndexOpen

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Apollo VCL Component Reference > TApolloTable > TApolloTable Methods >

IndexOpen

Declaration

function IndexOpen( sFileName: String ): Integer;

Description

Opens an index file. When a single NTX or IDX is opened, it becomes the controlling order and the record pointer in the table is positioned to logical top.

 

If multiple indexes are opened (NTX/IDX), the last one opened becomes the controlling order.

 

If multiple index files are attached to the table, they must all be opened if they are to be maintained by data changes or record additions.

 

Compound indexes (CDX/NSX) are automatically opened when their associated table is opened if they have the same file name as the DBF with an extension that indicates the index driver in use (CDX for SDEFOX and NSX for SDENSX). These indexes are known as structural or production indexes.

 

If the compound index has a different name, use IndexOpen to open it. When compound indexes are opened, there is no default controlling order. An explicit call to SetOrder must be made to set a controlling order. GoTop must also be used to position the record pointer to logical top.

image\tip.gif All index files listed in the ExtraIndexes list will be opened automatically when the table is opened and closed when the table is closed.

Parameters

sFileName: The name of the index file including full path (for local tables) and extension.

image\tip.gif When working with a remote table via Apollo Database Server, you may only open indexes within the same Database directory as specified in the DatabaseName property of the TApolloTable component making this method call. The remote client cannot specify a physical server drive/path location and must use the defined server alias instead.  Any physical drive/path included on the file sFileName parameter will be ignored for remote tables.

Return Value

Zero is returned for compound indexes. Single indexes (NTX and IDX) return an index area. This is the order identifying number of the index relative to this work area. This value should be retained in a global variable for future SetOrder calls.

 

To retrieve index areas for tags residing in compound indexes, use TagArea. If tag names are unknown, they may be enumerated by calling TagName with a consecutive series of area numbers. The first TagName returned with a length of zero signals the end of the list.

Delphi Example

// Open file and set order

ApTbl.Open;

iCustIndex2 := ApTbl.IndexOpen('c:\Apollo\Data\sxcust2.ntx' );

iCustIndex3 := ApTbl.IndexOpen('c:\Apollo\Data\sxcust3.ntx' );

iRetVal := ApTbl.SetOrder( iCustIndex2 );

C++Builder Example

// Open file and set order

ApTbl->Open();

iCustIndex2 = ApTbl->IndexOpen("c:\\Apollo\\Data\\sxcust2.ntx" );

iCustIndex3 = ApTbl->IndexOpen("c:\\Apollo\\Data\\sxcust3.ntx" );

iRetVal = ApTbl->SetOrder( iCustIndex2 );

See Also

ExtraIndexes, Index, IndexClose, IndexKey, IndexFileName, IndexOrd, IndexTag, SetOrder, TagArea, TagName