xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

OrdKeyDel()

Removes an index key from a custom built index.

Syntax

OrdKeyDel( [<nOrder>|<cIndexName>], ;
           [<cIndexFile>]         , ;
           [<xIndexValue>]          ) --> lSuccess

Arguments

<nOrder>
A numeric value specifying the ordinal position of the custom index open in a work area. Indexes are numbered in the sequence of opening, beginning with 1. The value zero identifies the controlling index.
<cIndexName>
Alternatively, a character string holding the symbolic name of the open custom index can be passed. It is analogous to the alias name of a work area. Support for <cIndexName> depends on the RDD used to open the index. Usually, RDDs that are able to maintain multiple indexes in one index file support symbolic index names, such as DBFCDX, for example.
<cIndexFile>
<cIndexFile> is a character string with the name of the file that stores the custom index. It is only required when multiple index files are open that contain indexes having the same <cIndexName>.
<xIndexValue>
This is the index value to be added to the index for the current record. It must be of the same data type as the value returned by the index expression. If omitted, <xIndexValue> is obtained by evaluating the index expression with the data of the current record.

Return

The function returns .T. (true) if the current record is successfully removed from the index, otherwise .F. (false) is returned.

Description

OrdKeyDel() is used in conjunction with OrdKeyAdd() to maintain a custom built index programmatically. Custom built indexes are not automatically updated by the RDD but are initially empty. OrdKeyDel() removes the current record from a custom index, if it is included in the specified index.

If no parameters are passed, OrdKeyDel() evaluates the index expresssion with the data of the current record to obtain <xIndexValue>. The record is removed from the index when it is found.

OrdKeyDel() fails if the record pointer is positioned on Eof(), if the specified index is not a custom index, if the specified index does not exist, or if the current record is not included in the custom index.

Info

See also:DbOrderInfo(), DbGoto(), INDEX, OrdKey(), OrdKeyAdd(), OrdKeyVal()
Category: Database functions , Index functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example creates a regular and a custom index holding five
// index keys. The last index key is removed from the custom index.

   REQUEST Dbfcdx

   PROCEDURE Main
      USE Customer VIA "DBFCDX"
      INDEX ON Upper(LastName) TAG NAME    TO Cust01
      INDEX ON Upper(LastName) TAG NAMESET TO Cust01 CUSTOM

      OrdSetFocus( "NAME" )
      GO BOTTOM
      ? OrdKeyVal()                    // result: WATERS

      GO TOP
      FOR i:=1 TO 5
         OrdKeyAdd( "NAMESET" )
         SKIP
      NEXT

      OrdSetFocus( "NAMESET" )
      GO BOTTOM
      ? OrdKeyVal()                    // result: CHAUCER

      ? OrdKeyDel( "NAMESET" )
      ? OrdKeyVal()                    // result: NIL

      USE
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe