xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

OrdKeyCount()

Retrieves the total number of keys included in an index.

Syntax

OrdKeyCount( [<nOrder>|<cIndexName>][,<cIndexFile>] ) --> nKeyCount

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.
<cIndexName>
Alternatively, a character string holding the symbolic name of the open 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 index. It is only required when multiple index files are open that contain indexes having the same <cIndexName>.

Return

The function returns the number of keys included in the specified index. If no parameter is passed, the controlling index is used. If the specified index does not exist, a runtime error is generated.

Description

The function counts the index keys present in the specified index. For this, it recognizes a possible FOR condition and/or scope set with OrdScope(). If no FOR condition and no scope is defined for the index, the return value of OrdKeyCount() is identical with LastRec(), which returns the physical number of records in a work area.

Scopes and FOR conditions restrict the logical visibility of records, so that OrdKeyCount() represents the number of records that can be navigated to using SKIP. This information is especially required for programming scroll bars in browse views.

Info

See also:DbOrderInfo(), DbGoto(), DbSkip(), LastRec(), OrdKeyGoto(), OrdKeyNo(), OrdScope()
Category: Database functions , Index functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example compares return values of LastRec() and OrdKeyCount()
// when the logical visibility of records is unrestricted vs. restricted
// with OrdScope().

   #include "Ord.ch"

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

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

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

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

      USE
   RETURN

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