since the search in an archive is very slow I thought of using an array but I have difficulty in counting the number in the same position
first I convert the archive to an array
Local aData := oDbf:dbftoarray()I have an array of 57 columns and 10078 rows
to give an example I have to look for the number 34 in the first position, which in the archive is the third field
? freq(oDbf,34,1,10078)
freq(oDbf,numero,npos,nRowMax)
nRowMax is the maximum number record where I have to look for it
Function test()
local oDbf
local cDir := ".\data\"
oDbf:= TDatabase():Open( ,cDir+"demo", "DBFCDX", .T. )
? freq(oDbf,34,1,10078)
return nil
Function freq(oDbf,numero,npos,nRowMax)
Local aData := oDbf:dbftoarray()
Local nColMax := 57
LOCAL k, j, nPosi
LOCAL nCount := 0
For k = 1 to nRowMax
FOR j = 1 TO nColMax
nPosi := AScan( aData, { |a| a[ nPos+2 ] = numero } )
IF nPosi = nPos+2
// increase Counter
nCount:=nCount + 1
ENDIF
NEXT
NEXT
? nCount
return nilany help pls
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com