Command GO Foundation

Positions the record pointer to a specific record in the current or in the specified workarea

GO[TO] <xRecordID> | BOTTOM | TOP [IN <nWorkArea> | <cAlias> ]
<xRecordID> is an expression used to clearly identify the data record. Its meaning depends on the database engine managing the database file. For DBFDBE files, <xRecordID> is a numeric value indicating the record number (RecNo()) referenced by the record pointer.
The option BOTTOM positions the record pointer on the last logical record in the current work area.
The option TOP positions the record pointer on the first logical record in the current work area.
IN <nWorkArea>
<nWorkArea> is a positive integer specifying the ordinal number of the work area being selected.
IN <cAlias>
This argument is either a literal alias name or a character expression containing the alias name in parentheses. The alias name indicates the work area whose files are to be closed.

The file command GO (or GOTO) positions the record pointer in the current work area or in the work area specified using th eIN clause. A value must be specified for <xRecordID> to clearly identify the desired record. For DBF files, this is the record number (RecNo()). For another file format, it might have a different basis, such as the value of the primary key.

The function works with the physical records in a file and does not consider logical records. Therefore, each record can be jumped to with GO, even if the record does not match the current filter condition or the record is marked as "Deleted" and SET DELETED ON is set. If the value for <xRecordID> is not found in the file, GO positions the record pointer on the "phantom record" (for DBF files, it is LastRec()+1). The function Eof() returns the value .T. (true) and, if the file is empty, the function Bof() also returns .T. (true).

Specifying the option TOP or BOTTOM positions the record pointer to the first or last logical record in the current work area. If no filter is active and no index file is open, the record pointer is positioned to the first or last physical record.

The functions DbGoto(), DbGoTop() and DbGoBottom() are the functional equivalents of the command GO.

GO RecNo() causes the file buffers in the work area to be written to the corresponding files. In multi-user operation on a network, changed data is then visible to other work stations.

// The example shows different ways to call the GO command. 

   LOCAL  nRecordID := 69 

   USE Customer NEW 

   ? LastRec()             // result: 100 

   GO 50 
   ? RecNo()               // result: 50 

   GO 150                  // record is > LastRec() 
   ? RecNo()               // result: 101 
   ? Eof()                 // result: .T. 

   GO TOP 
   ? RecNo()               // result: 1 

   GO 7 + 15 
   ? RecNo()               // result: 22 

   ? RecNo()               // result: 100 

   GO nRecordID            // specify variable 
   ? RecNo()               // result: 69 

   CLOSE Customer 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.