Determine when end of file is encountered

     EOF() --> lBoundary


     EOF() returns true (.T.) when an attempt is made to move the record
     pointer beyond the last logical record in a database file; otherwise, it
     returns false (.F.).  If there is no database file open in the current
     work area, EOF() returns false (.F.).  If the current database file
     contains no records, EOF() returns true (.T.).


     EOF() is a database function used to test for an end of file boundary
     condition when the record pointer is moving forward through a database
     file.  Any command that can move the record pointer can set EOF().

     The most typical application is as a part of the <lCondition> argument
     of a DO WHILE construct that sequentially processes records in a
     database file.  Here <lCondition> would include a test for .NOT. EOF(),
     forcing the DO WHILE loop to terminate when EOF() returns true (.T.).

     EOF() and FOUND() are often used interchangeably to test whether a SEEK,
     FIND, or LOCATE command failed.  With these commands, however, FOUND()
     is preferred.

     When EOF() returns true (.T.), the record pointer is positioned at
     LASTREC() + 1 regardless of whether there is an active SET FILTER or SET
     DELETED is ON.  Further attempts to move the record pointer forward
     return the same result without error.  Once EOF() is set to true (.T.),
     it retains its value until there is another attempt to move the record

     By default, EOF() operates on the currently selected work area.  It can
     be made to operate on an unselected work area by specifying it within an
     aliased expression (see example below).


     .  This example demonstrates EOF() by deliberately moving the
        record pointer beyond the last record:

        USE Sales
        GO BOTTOM
        ? EOF()            // Result: .F.
        ? EOF()            // Result: .T.

     .  This example uses aliased expressions to query the value of
        EOF() in unselected work areas:

        USE Sales NEW
        USE Customer NEW
        ? Sales->(EOF())
        ? Customer->(EOF())

     .  This example illustrates how EOF() can be used as part of a
        condition for sequential database file operations:

        USE Sales INDEX CustNum NEW
        DO WHILE !EOF()
           nOldCust := Sales->CustNum
           nTotalAmount := 0
           DO WHILE nOldCust = Sales->CustNum .AND. (!EOF())
              ? Sales->CustNum, Sales->Description, ;
              nTotalAmount += Sales->SaleAmount
           ? "Total amount: ", nTotalAmount

 Files   Library is CLIPPER.LIB.


4 responses to “C5_EOF

  1. Pingback: C5_SKIP | Viva Clipper !

  2. Pingback: C5_SELECT | Viva Clipper !

  3. Pingback: C5_SEEK | Viva Clipper !

  4. Pingback: C5_LOCATE | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.