xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Eof()

Determines when the end-of-file is reached.

Syntax

Eof() --> lIsEndOfFile

Return

The function returns .T. (true) when the record pointer in a work area has reached the end of file, otherwise .F. (false).

Description

The Eof() function indicates if the record pointer has reached the logical end-of-file mark during database navigation. The end-of-file mark is a state variable that exists for each work area. Eof() operates in the current work area unless it is used within an aliased expression.

The Eof() state of a work area is evaluated each time the record pointer is moved with commands like SKIP, SEEK or LOCATE or their functional equivalents. When Eof() returns .T. (true), this value is retained until the record pointer is moved to a different record, or a new record is appended.

Note that Eof() is always .T. (true) when a database has no records, and it returns always .F. (false) when a work area is not in use.

Info

See also:Bof(), DbSeek(), DbSkip(), DO WHILE, Found(), GO, LastRec(), LOCATE, RecNo(), SEEK, SKIP
Category: Database functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example illustrates the Eof() 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

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

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

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

      // Note: from record #10 we skipped 45 records
      // to hit end-of-file, and ended up at record #220
      // That's because the database is indexed.
      ? EoF(), nCount, Recno()         // result: .T.   220   225

      ? EoF(), Empty(LastName)         // result: .T.  .T.
      SKIP 0
      ? EoF(), Empty(LastName)         // result: .T.  .T.

      SKIP -1
      ? EoF(), LastName                // result: .F.  Waters

      SET SCOPETOP    TO "G"           // restrict logical navigation
      SET SCOPEBOTTOM TO "M"           // restrict logical navigation

      GO BOTTOM
      ? EoF(), LastName                // result: .F.  Miller

      SKIP                             // EoF reached due to scope
      ? EoF(), LastName                // result: .T. (empty)

      CLOSE Customer
   RETURN

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