xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

BoF()

Determines if the record pointer reached the begin-of-file boundary.

Syntax

BoF() --> lBeginOfFile

Return

The function returns .T. (true) when an attempt is made to move the record pointer in a work area backwards beyond the first logical record, or when the database in a work area has no records. In all other situations, Bof() returns .F. (false).

Description

The database function Bof() is required to determine if the record pointer has reached the begin-of-file during a backwards oriented database navigation. This can only be achieved with passing a negative value to SKIP or DbSkip(). Once the begin-of-file is reached, the record pointer remains at the first logical record and Bof() returns .T. (true). Bof() continues to return .T. (true) until the record pointer is moved forwards again.

BoF() operates on logical records unless no index is open in the work area and no filter or scope is set. With no filter, index or scope, Bof() returns .T. (true) when attempting to move the record pointer to a record number < 1.

The function operates in the current work area. To query the begin-of-file in a different work area, use an aliased expression.

Info

See also:DbGoto(), DbSkip(), Eof(), GO, INDEX, SET DELETED, SET FILTER, SET SCOPE, SKIP
Category: Database functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example illustrates the Bof() state of a work area during
// physical and logical record pointer movement.

   #include "Ord.ch"

   PROCEDURE Main
      LOCAL nCount := 0

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

      ? BoF(), LastName                // result: .F. Alberts

      // physical movement of record pointer
      GOTO 10
      ? BoF(), nCount, Recno()         // result: .F.   0   10

      // logical movement of record pointer
      DO WHILE .NOT. BoF()
         SKIP -1
         nCount ++
      ENDDO

      // Note: from record #10 we skipped 5 records back
      // to hit begin-of-file, and ended up at record #20
      // That's because the database is indexed.
      ? BoF(), nCount, Recno()         // result: .T.   5   20

      ? BoF(), LastName                // result: .T. Alberts
      SKIP 0
      ? BoF(), LastName                // result: .T. Alberts

      SKIP 1
      ? BoF(), LastName                // result: .F. Becker

      SET SCOPETOP TO "G"              // restrict logical navigation

      GO TOP
      ? BoF(), LastName                // result: .F. Grastner

      SKIP -1                          // BoF reached due to scope
      ? BoF(), LastName                // result: .T. Grastner

      CLOSE Customer
   RETURN

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