xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

OrdWildSeek()

Searches a value in the controlling index using wild card characters.

Syntax

OrdWildSeek( <cWildCardString>, ;
            [<lCurrentRec>]   , ;
            [<lBackwards>]      ) --> lFound

Arguments

<cWildCardString>
This is a character string to search in the controlling index. It may include the wild card characters "?" and "*". The question mark matches a single character, while the asterisk matches one or more characters.
<lCurrentRec>
This parameter defaults to .F. (false) causing OrdWildSeek() to begin the search with the first record included in the controlling index. When .T. (true) is passed, the function begins the search with the current record.
<lBackwards>
If .T. (true) is passed, OrdWildSeek() searches <cWildCardString> towards the begin of file. The default value is .F. (false), i.e. the function searches towards the end of file.

Return

The function returns .T. (true) if a record matching <cWildCardString> is found in the controlling index, otherwise .F. (false) is returned.

Description

OrdWildSeek() searches a character string that may include wild card characters in the controlling index. This allows for collecting subsets of records based on an approximate search string. Records matching the search string are found in the controlling index, and the record pointer is positioned on the found record.

When a matching record is found, the function Found() returns .T. (true) until the record pointer is moved again. In addition, both functions, BoF() and EoF() return .F. (false).

If the searched value is not found, OrdWildSeek() positions the record pointer on the "ghost record" (Lastrec()+1), and the function Found() returns .F. (false), while Eof() returns .T. (true). The SET SOFTSEEK setting is ignored by OrdWildSeek().

Info

See also:DbSeek(), LOCATE, OrdFindRec(), OrdKeyGoto(), WildMatch()
Category: Database functions , Index functions , xHarbour extensions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example uses two wildcard search strings to show
// possible search results of OrdWildSeek()

   PROCEDURE Main
      LOCAL aCust := {}

      USE Customer
      INDEX ON Upper(LastName) TO Cust01

      DO WHILE OrdWildSeek( "*MAN?", .T. )
         AAdd( aCust, FIELD->Lastname )
      ENDDO

      AEval( aCust, {|c| QOut(c) } )
      // Found records:
      //   Dormann
      //   Feldman

      GO TOP
      aCust := {}
      DO WHILE OrdWildSeek( "*EL*", .T. )
         AAdd( aCust, FIELD->Lastname )
      ENDDO

      AEval( aCust, {|c| QOut(c) } )
      // Found records:
      //   Feldman
      //   Hellstrom
      //   Keller
      //   Reichel
      USE
   RETURN

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