_DBSeek( ) API Library Routine

See Also   Example

Searches an indexed table in the current work area for the first record whose index key matches the value val.

Syntax

long _DBSeek(Value FAR *val)
Value FAR *val;            /* Sought value. */

Remarks

If _DBSeek( ) finds a matching record, it moves the record pointer to the matching record and returns the record number. The match must be exact unless you SET EXACT is set to OFF. If _DBSeek( ) doesn't find a matching record, it returns 0. If no match is found and SET NEAR is set to ON, the record pointer is positioned immediately after the closest matching record. If SET NEAR is set to OFF, the record pointer is positioned at the end of the file.

If the matching record is an added buffered record that has not been committed, the value returned by _DBSeek( ) differs from the value returned by RECNO( ). RECNO( ) returns a negative value, indicating the record is buffered. The value returned by _DBSeek( ) is one greater than the number of records in the table plus the number of buffered records before the matching record.

If an error occurs, _DBSeek( ) returns a negative integer whose absolute value is a Visual FoxPro error number.

When seeking a numeric field, val must be set to ev_type 'N', even if that field has no decimal digits.  If val has an ev_type of 'I', _DBSeek( ) will return the internal error number -302, "Data type mismatch".

For more information on how to create an API library and integrate it with Visual FoxPro, see Chapter 28, Accessing the Visual FoxPro API, in the Programmer's Guide.