xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HS_Add()

Adds a text string entry to a HiPer-SEEK index file.

Syntax

HS_Add( <nHsxHandle>, <bText> ) --> nIndexEntry

Arguments

<nHsxHandle>
This is the numeric file handle of the HiPer-SEEK index file to add a new entry to. The file handle is returned from HS_Open() or HS_Create().
<bText>
The second parameter is a code block which returns the character string to add to the HiPer-SEEK index file.

Return

The function returns a numeric value. Positive values identify the ordinal number of the new index entry, while negative numbers are error codes:

Error codes of HS_Add()
ValueDescription
-4Error while attempting to seek during buffer flushing.
-6Write error during buffer flushing.
-16Invalid parameters are passed.
-18Illegal HiPer-SEEK index file handle.

Description

Function HS_Add() is used to fill a HyPer-SEEK index file after it is created with HS_Create(), or opened with HS_Open(). The code block <bText> must return a character string. HS_Add() calculates an index key for this text string and adds it to the HiPer-SEEK index file.

Info

See also:HS_Delete(), HS_Replace()
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 outlines the steps required to create a
// HiPer-SEEK index file and fill with information
// from a database file.

   PROCEDURE Main
      LOCAL bIndex, nHandle, nIndex

      CLS
      USE Customer
      SET DELETED OFF

      nHandle := HS_Create( "Customer.hsx", 8, 3, .F., 2 )
      bIndex  := {|| Trim(LastName)+" "+Trim(FirstName) }

      DO WHILE .NOT. Eof()
         nIndex := HS_Add( nHandle, bIndex )
         IF nIndex <> Recno()
            ? "Error adding index:", nIndex
         ENDIF
         SKIP
      ENDDO

      HS_Close( nHandle )
      USE
   RETURN

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