xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HS_Verify()

Verifies a HS_Next() match against the index key.

Syntax

HS_Verify( <xIndexKey>, <cSearch> ) --> lMatched

Arguments

<xIndexKey>
This is either a code block holding the index key, or a character string holding the index key expression. A code block is recommended, since it does not need to be macro compiled.
<cSearch>
The searched value must be passed as a character string.

Return

The function returns .T. (true) when <cSearch> is contained anywhere in the result of the code block, or index value, otherwise .F. (false) is returned.

Description

HS_Verify() is used to make sure that the value found in a HiPer-SEEK index file actually matches the data in the corresponding database file. The HiPer-SEEK algorithm calculates fixed size hash keys from text strings. This makes it possible that two different text strings result in the same hash key so that a search may result in false positives. HS_Verify() prevents from finding false positives by comparing the search string against the data stored in the database.

Info

See also:HS_Next()
Category: Database functions , HiPer-SEEK functions , Index functions , xHarbour extensions
Source:rdd\hsx\hsx.c
LIB:lib\xhb.lib
DLL:dll\xhbdll.dll

Example

// The example demonstrates how HiPer-SEEK search operations
// are verified against a database.

   PROCEDURE Main
      LOCAL cIndex, bIndex, nHandle
      LOCAL nRecno, cSearch := "ller"

      CLS
      USE Customer ALIAS Cust

      cIndex := 'Trim(Cust->LastName) +'
      cIndex +=  '" "'
      cIndex += '+ Trim(Cust->FirstName)'
      bIndex := &( "{||" + cIndex + "}" )

      nHandle := HS_Index( "Customer.hsx", cIndex, 3, 0, 16 )

      IF nHandle < 0
         ? "HiPer-SEEK index creation failed with error:", nHandle
         QUIT
      ENDIF

      // define search string and find first index entry
      HS_Set( nHandle, cSearch )
      nRecno := HS_Next( nHandle )

      DO WHILE nRecno > 0
         DbGoto( nRecno )

         IF HS_Verify( bIndex, cSearch )
            ? "Matched :", Eval( bIndex )
         ELSE
            ? "No match:", Eval( bIndex )
         ENDIF

         // find next index entry
         nRecno := HS_Next( nHandle )
      ENDDO

      HS_Close( nHandle )
      USE
   RETURN

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