<< Click to Display Table of Contents >> Navigation: Apollo API Listing > sx_KeyDrop |
Declare Function sx_KeyDrop Lib "Apollo9.dll"
(ByVal cpTagName As Any)
As Integer
BOOL FAR PASCAL sx_KeyDrop (BYTEP cpTagname);
Deletes a key to the specified index order.
Note: This function can only be used on indexes that were created using the IDX_EMPTY constant for the iOption parameter of sx_Index or sx_IndexTag.
cpTagName : The index tag the key is dropped from. Passing a NULL will drop the key from the currently active index tag.
True if the key was successfully removed, False if not.
iDBF = sx_Use( "c:\data\test.dbf", "test", EXCLUSIVE, SDEFOX )
iOrd = sx_Index( "test.idx", "Upper(LAST)", IDX_EMPTY, 0, &0 )
sx_GoTop
If sx_KeyAdd( 0 ) Then
MsgBox "Key added successfully."
Else
MsgBox "Key add failed!"
End If
' Drop the key for the current record
If sx_KeyDrop( 0 ) Then
MsgBox "Key removed successfully."
Else
MsgBox "Key drop failed!"
End If
/*
Maintain our own user defined conditional index.
Add or Delete all of the records to the RYO index "CUSTOM" that match the cpLastName parameter based on the bAdd parameter. Assume that there is an index called "LAST".
*/
Void MaintainCustom(BYTEP cpLastName, BOOL bAdd)
{
SHORT iCurOrder;
//Save the currently active order
iCurOrder = sx_IndexOrd();
if (bAdd) //Are we adding a key?
{
//Set the order to the "Last" tag
sx_SetOrder(sx_TagArea("LAST")):
sx_Seek(cpLastName);
while (!memcmp(cpLastName, sx_GetString("LAST"), strlen(cpLastName)))
{
sx_KeyAdd("CUSTOM");
sx_Skip(1);
}
//Restore the order
sx_SetOrder(iCurOrder);
}
else
{
//Set the order to the custom index
sx_SetOrder(sx_TagArea("CUSTOM"));
while (sx_Seek((BYTEP)"Smith"))
{
sx_KeyDrop((BYTEP)caTagName);
}
//Reset the order
sx_SetOrder(iCurOrder);
}
return;
}