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
- Code: Select all Expand view RUN
- 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
- Code: Select all Expand view RUN
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 nil
any help pls