Hello
with xHarbour you have to use HSX.LIB
Maurizio
www.nipeservice.com
so it's an error number.HS_Index( <cFileName> , ;
<cExpression> , ;
[<nKeySize>] , ;
[<nOpenMode>] , ;
[<nBufferSize>], ;
[<lCaseInsens>], ;
[<nFilterSet>] ) --> nErrorCode
// The example creates a new, populated HiPER-SEEK index for
// a customer database.
PROCEDURE Main
LOCAL cIndex, nHandle
CLS
USE Customer ALIAS Cust
cIndex := 'Trim(Cust->LastName) +'
cIndex += '" "'
cIndex += '+ Trim(Cust->FirstName)'
nHandle := HS_Index( "Customer.hsx", cIndex, 3, 0, 16 )
IF nHandle >= 0
? "HiPer-SEEK index successfully created with"
?? HS_KeyCount( nHandle), "index entries"
HS_Close( nHandle )
ELSE
? "HiPer-SEEK index creation failed with error:", nHandle
ENDIF
USE
RETURN
// The example demonstrates the pattern matching algorithm employed
// by WildMatch() and how the function can be used as filter condition
// for a database
PROCEDURE Main
LOCAL cStr := "The xHarbour compiler"
? WildMatch( "bo?" , cStr, .F. ) // result: .F.
? WildMatch( "bo?" , cStr, .T. ) // result: .F.
? WildMatch( "*bo" , cStr, .F. ) // result: .T.
? WildMatch( "*bo" , cStr, .T. ) // result: .F.
? WildMatch( "The" , cStr, .F. ) // result: .T.
? WildMatch( "The" , cStr, .T. ) // result: .F.
? WildMatch( "The*r", cStr, .F. ) // result: .T.
? WildMatch( "The*r", cStr, .T. ) // result: .T.
? WildMatch( "The?x", cStr, .F. ) // result: .T.
? WildMatch( "The?x", cStr, .T. ) // result: .F.
USE Customer
SET FILTER TO WildMatch( "W*s", FIELD->LastName )
GO TOP
DbEval( {|| QOut( FIELD->LastName ) } )
// Output: Names starting with "W" and ending with "s"
// Walters
// Waters
CLOSE Customer
RETURN
WildMatch() is a pattern matching function that searches a string for a search pattern. If the search pattern is found, the function returns .T. (true).
WildMatch() operates similarly to OrdWildSeek() but can be used as part of a SET FILTER condition on an unindexed database.
* Example 1 - Indexes the whole dbf using hs_index()
LOCAL cExpr := "test->FIRST + test->LAST + test->STREET + test->CITY"
LOCAL nCount := 0, lStrict := .F.
LOCAL cSearch := "Steve John Robert"
LOCAL GetList := {}
CLS
USE test EXCL
IF !file("TEST.HSX")
@ 0,0 "Building HiPer-SEEK Index..."
hs_Index( "TEST.HSX", cExpr, 2 )
?? "Done!"
Inkey(1)
CLS
ENDIF
WHILE .T.
cSearch := PadR( cSearch, 59 )
@ 0,0 SAY "Search Values.....:" GET cSearch
@ 1,0 SAY "Strict Match (Y/N):" GET lStrict PICTURE "Y"
READ
IF LastKey() == K_ESC
CLS
EXIT
ENDIF
cSearch := AllTrim( cSearch )
@ 3,0 SAY "Setting HiPer-SEEK Filter ..."
nCount := hs_Filter( "TEST.HSX", cSearch, iif( lStrict, cExpr, "" ))
?? "Done!"
@ 4,0 SAY LTrim( Str( nCount )) + " records meeting filter condition."
@ 6,0 SAY "Press any key to browse the matching records..."
Inkey(0)
GO TOP
Browse()
CLS
ENDDO
* Example 2 - Adds strings manually to build the index using hs_add().
local nRec, h, bExpr
use test exclusive
h := hs_Open( "TEST.HSX", 10, 1 )
bExpr := { || test->mymemo }
DO WHILE !eof()
nRec := hs_Add( h, bExpr )
IF nRec < 1 .OR. nRec != RecNo()
? "Error adding record " + LTrim( Str( RecNo() )) + "!"
ENDIF
SKIP
ENDDO
static aKunden
function SearchFile( suchbeg )
local nLocation, cData
local nOffset := 0
local cDBF := ( "kunden.dbf" )
local nPos := 0
suchbeg := ALLTRIM(Upper(suchbeg))
cData := Upper(MemoRead( cDBF ))
if Len(cData ) < 1
MsgInfo("Not Data to Search","File Error")
Return Nil
endif
nOffset := 0
do while .t.
nPos := INT( AT( suchbeg, cData, nOffset ))
nLocation := INT( ( nPos - Header() ) / RecSize() ) + 1
nOffset := Header() + nLocation * RecSize() //+ RecSize()
if nPos > 0 .and. nPos < Header()
else
if nLocation < 1
Exit
else
select kunden
goto nLocation
if DELETED() = .F.
aAdd( aKunden, getrec() )
endif
endif
endif
enddo
Return Nil
//----------------------------------------------------------------------------//
But it seems not possible.
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 36 guests