xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

OrdKeyVal()

Retrieves the index value of the current record from the controlling index.

Syntax

OrdKeyVal() --> xIndexValue

Return

The function returns the index value of the current record. The return value is NIL if the current record is not included in the controlling index or if there is no controlling index.

Description

The function retrieves the index value for the current record from the index file holding the controlling index, not from the database file. This can be advantageous when an index expression is comprised of multiple fields. Their values can be assigned to a memory variable with one function call, rather than accessing multiple field variables individually.

Info

See also:DbOrderInfo(), INDEX, IndexKey(), OrdCreate(), OrdFor(), OrdKey(), OrdKeyNo(), OrdName(), OrdNumber()
Category: Database functions , Index functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example uses the index value to display Lastname and Firstname
// instead of field variables.

   PROCEDURE Main
      LOCAL cName

      USE Customer
      INDEX ON Upper( LastName + FirstName ) TO Cust01

      ? FieldPos( "FirstName" )            // result: 2
      ? FieldPos( "MiddleName" )           // result: 3
      ? FieldPos( "LastName" )             // result: 4

      ? FieldLen( 2 )                      // result: 20
      ? FieldLen( 4 )                      // result: 20

      cName := OrdKeyVal()
      ? Trim( Right(cName, 20)), Trim( Left(cName,20) )

      USE
   RETURN

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