xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

SET SOFTSEEK

Enables or disables relative seeking.

Syntax

SET SOFTSEEK on | OFF | ( <lOnOff> )

Arguments

on | OFF | ( <lOnOff> )
This option toggles whether the SEEK command employs relative seeking or not. The default is OFF or .F. (false), i.e. SEEK searches for an exact match. To change the setting use ON or .T. (true) as parameter. The parameter can also be specified as a logical expression enclosed in parentheses.

Description

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.

Info

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

Example

// 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

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