xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

OrdKeyNo()

Returns the logical record number of the current record.

Syntax

OrdKeyNo( [<nOrder>|<cIndexName>], [<cIndexFile>] ) --> nOrdKeyNo

Arguments

<cIndexName>
This is a character string holding the symbolic name of the index to query. It is analogous to the alias name of a work area. Support for <cIndexName> depends on the RDD used to create the index. Usually, RDDs that are able to maintain multiple indexes in one index file support symbolic index names, such as DBFCDX, for example.
<nOrder>
Optionally, 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.
<cIndexFile>
<cIndexFile> is a character string with the name of the file that stores the index. It is only required when multiple index files are open that contain indexes having the same <cIndexName>.

Return

The function returns the logical record number of the current record as a numeric value. Logical record numbers are in the range of 1 to OrdKeyCount() and depend on the controlling index. If the current record is not included in the index, the return value is zero.

Description

OrdKeyNo() is used to determine the logical record number of the current record. The logical record number represents the position of a record in the controlling index, while the physical record number Recno() represents a record's position in the database. Physical record movement is accomplished using function DbGoTo(), while logical record pointer movement is done with OrdKeyGoTo().

Info

See also:DbOrderInfo(), INDEX, OrdKey(), OrdKeyCount(), OrdKeyGoTo(), OrdKeyRelPos(), OrdListAdd(), OrdNumber(), OrdScope(), Recno()
Category: Database functions , Index functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example outlines the difference between physical and logical
// record numbers in an indexed database without and with scope.

   #include "Ord.ch"

   PROCEDURE Main
      USE Customer
      INDEX ON Upper(LastName+Firstname)  TAG Name TO Cust01

      ? LastRec()                      // result: 225
      ? OrdKeyCount()                  // result: 225

      GO TOP
      ? Recno()                        // result:  15
      ? OrdKeyNo()                     // result:   1

      GO BOTTOM
      ? Recno()                        // result: 123
      ? OrdKeyNo()                     // result: 225

      OrdScope( TOPSCOPE   , "E" )
      OrdScope( BOTTOMSCOPE, "G" )

      ? LastRec()                      // result: 225
      ? OrdKeyCount()                  // result:  13

      GO TOP
      ? Recno()                        // result:  87
      ? OrdKeyNo()                     // result:   1

      GO BOTTOM
      ? Recno()                        // result: 207
      ? OrdKeyNo()                     // result:  13

      USE
   RETURN

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