xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

OrdFindRec()

Searches a record number in the controlling index.

Syntax

OrdFindRec( <nRecno>, [<lCurrentRec>] ) --> lFound

Arguments

<nRecno>
This is a numeric value specifying the phyiscal record number to find in the controlling index. Physical record numbers are in the range of 1 to Lastrec().
<lCurrentRec>
This parameter defaults to .F. (false) causing OrdFindRec() to begin the search with the first record included in the controlling index. When .T. (true) is passed, the function begins the search with the current record.

Return

The function returns .T. (true) if a record is found in the controlling index that has the record number <nRecno>, otherwise .F. (false) is returned.

Description

OrdFindRec() searches a record number in the controlling index. It is similar to DbSeek(), which searches an index key. If OrdFindRec() finds the record number <nRecno> in the controlling index, it positions the record pointer on the found record, and Function Found() returns .T. (true) until the record pointer is moved again. In addition, both functions, BoF() and EoF() return .F. (false).

When a matching record number is not found, the record pointer is positioned on the "ghost record" (Lastrec()+1), and the function Found() returns .F. (false), while Eof() returns .T. (true).

Info

See also:DbOrderInfo(), DbSeek(), OrdKeyGoto(), OrdKeyVal(), OrdWildSeek()
Category: Database functions , Index functions , xHarbour extensions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example navigates the record pointer via the controlling index
// using physical and logical record numbers,

   REQUEST Dbfcdx

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

      OrdFindRec( 1 )                    // Physical first record
      ? Lastname, Recno(), OrdKeyNo()    // result: Miller    1  15

      OrdFindRec( LastRec() )            // Physical last record
      ? Lastname, Recno(), OrdKeyNo()    // result: Smith    22  19

      OrdKeyGoto( 1 )                    // Logical first record
      ? Lastname, Recno(), OrdKeyNo()    // result: Alberts  20   1

      OrdKeyGoto( OrdKeyCount() )        // Logical last record
      ? Lastname, Recno(), OrdKeyNo()    // result: Waters   15  22

      OrdFindRec( -1 )                   // Non-existent record
      ? Lastname, Recno(), OrdKeyNo()    // result:          23   0

      ? Bof(), Eof(), Found()            // result: .T.  .T.  .F.
      USE
   RETURN

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