sx_IndexOpen

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_IndexOpen

VB Declaration

Declare Function sx_IndexOpen Lib "Apollo9.dll"

(ByVal cpFileName As String)

As Integer

C Declaration

SHORT FAR PASCAL sx_IndexOpen

(BYTEP cpFileName);

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 sx_IndexOpen to open it. When compound indexes are opened, there is no default controlling order. An explicit call to sx_SetOrder must be made to set a controlling order. sx_GoTop must also be used to position the record pointer to logical top.

Parameters

cpFileName: Name of the index file including full path and extension.

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 sx_SetOrder calls.

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

VB Example

' open file and set order

Cust = sx_Use("c:\vb\sde\sxcust.dbf", "cust", READWRITE, SDENTX)

CustIndex2 = sx_IndexOpen("c:\vb\sde\sxcust2.ntx")

CustIndex3 = sx_IndexOpen("c:\vb\sde\sxcust3.ntx")

iRetVal = sx_SetOrder(CustIndex2)

C Example

// open database and index files

iName = sx_Use((BYTEP) "names.dbf", (BYTEP) "names", READWRITE, SDENTX);

 

// check for existence of each index file

// if they do not exist, we'll create them

pFile = "names1.ntx";

if (!CFile::GetStatus(pFileName, status))

iNtx1 = sx_Index((BYTEP) pFile, (BYTEP) "upper(name)",

IDX_NONE, 0, (BYTEP) 0);

else

iNtx2 = sx_IndexOpen((BYTEP) pFile);

See Also

sx_Index, sx_IndexClose, sx_IndexKey, sx_IndexName, sx_IndexOrd, sx_IndexTag, sx_SetOrder, sx_TagArea, sx_TagName