xHarbour Reference Documentation > Command Reference |
Enables or disables relative seeking.
SET SOFTSEEK on | OFF | ( <lOnOff> )
The SET SOFTSEEK command changes the global setting for searching relatively with the SEEK command. The default setting is OFF. This setting is valid for all work areas. It can be overridden for individual work areas by calling the DbSeek() function in place of the SEEK command.
When SOFTSEEK is set to OFF, the SEEK command searches for an exact match with the searched value. If the value is not found, the record pointer is placed on the ghost record (Lastrec()+1) and function EoF() returns .T. (true).
When SOFTSEEK is set to ON and the searched value is not found, the record pointer is positioned on the record with the next higher index value. As a result, Eof() yields .F. (false), unless there is no higher index value.
Irrespective of the SOFTSEEK setting, function Found() returns .F. (false) when the searched value is not found.
Note: The SOFTSEEK setting is ignored for automatic SEEK operations that are performed due to SET RELATION in a child work area.
See also: | DbSeek(), Eof(), Found(), SEEK, SET INDEX, SET ORDER, SET RELATION |
Category: | Index commands , SET commands |
Source: | rdd\dbcmd.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates the effect of SOFTSEEK using a database // that contains "Jane" and "John" as names, but not "Jim" PROCEDURE Main USE Test INEX ON Name TO Test SET SOFTSEEK OFF SEEK "Jane" ? Found(), Eof(), Name // result: .T., .F., "Jane" SEEK "Jim" ? Found(), Eof(), Name // result: .F., .T., "" SET SOFTSEEK ON SEEK "Jim" ? Found(), Eof(), Name // result: .F., .F., "John" SEEK "John" ? Found(), Eof(), Name // result: .T., .F., "John" CLOSE Test RETURN
http://www.xHarbour.com