xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

IndexKey()

Returns the index expression of an open index.

Syntax

IndexKey( <nOrder> ) --> cIndexKey

Arguments

<nOrder>
A numeric value specifying the ordinal position of the index open in a work area. Indexes are numbered in the sequence of opening, beginning with 1. The value zero identifies the controlling index.

Return

The function returns the index key expression of the specified index as a character string. If the work area is unused, an empty string ("") is returned.

Description

The function is used to obtain the index key expression of an index open in a work area. The returned character string can be evaluated using the macro operator (&) to obtain the index value of the current database record. This is useful, for example, when data is edited by the user and written back to the database file. If this operation changes the index value of the controlling index, a screen update may be required, especially in browse views.

Note:  The function exists for compatibility reasons. It is recommended to use OrdKey() instead.

Info

See also:INDEX, IndexExt(), IndexOrd(), OrdCreate(), OrdKey(), OrdListAdd(), OrdNumber(), SET INDEX, SET ORDER, USE
Category: Database functions , Index functions
Source:rdd\rddord.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example creates two indexes and displays their
// key expressions.

   REQUEST DBFCDX

   PROCEDURE Main
      RddSetDefault( "DBFCDX" )
      USE Customer

      INDEX ON CustID                     TAG ID   TO Cust01
      INDEX ON Upper(LastName+FirstName)  TAG Name TO Cust01

      ? IndexOrd()               // result: 2

      ? IndexKey(0)              // result: Upper(LastName+FirstName)
      ? IndexKey(1)              // result: CustID
      ? IndexKey(2)              // result: Upper(LastName+FirstName)

      USE
   RETURN

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