Which is the fastest way to load the contents of a DBF into an Array.
Something faster than this:
- Code: Select all Expand view
- SELECT ("CUSTOMER")
DbGoTop()
do while !eof()
aadd(myarray, CUSTOMER->NAME)
dbskip()
enddo
Thank you
SELECT ("CUSTOMER")
DbGoTop()
do while !eof()
aadd(myarray, CUSTOMER->NAME)
dbskip()
enddo
aData := {}
ASizeAlloc( aData, CUSTOMER->( LASTREC() ) )
I don't think C could help much, because most of the time is spent reading the disk which is hardware dependent.
FUNCTION AGG_REC( cFile, aFile, nRecord )
LOCAL cDelete
LOCAL aRec := {}
LOCAL nFld, nNew
LOCAL nNuovi
LOCAL aNew := {}
LOCAL nStart := LEN( aFile )
LOCAL i
// se ci sono nuovi record prima crea i nuovi elementi dell'array vuoti
// if there are new records at first create new empty elements
IF nRecord > LEN( aFile )
nNuovi := nRecord - LEN( aFile )
FOR nNew := 1 TO nNuovi
aRec := {}
FOR nFld := 1 TO FCount()
IF fieldtype( nFld ) = "C" .OR. fieldtype( nFld ) = "M"
AADD( aRec , "" )
ENDIF
NEXT i
AADD( aFile , aRec )
AADD( aNew , nStart + nNew )
NEXT nNew
ELSE
AADD( aNew , nRecord )
ENDIF
SELECT &cFile
FOR nNew := 1 TO LEN( aNew )
i := aNew[ nNew ]
GOTO aNew[ nNew ]
aFile[ i , U_DELETE ] := cDelete
aFile[ i , U_DELETE ] := " "
aRec := {}
AADD( aRec , IIF( DELETED() , "D", " " ) )
FOR nFld := 1 TO FCount()
IF fieldtype( nFld ) = "C" .OR. fieldtype( nFld ) = "M"
AADD( aRec , UPPER( fieldget( nFld ) ) )
ENDIF
NEXT i
FOR nFld := 1 TO LEN( aFile[ i ] )
IF aFile[ i , nFld ] <> aRec[ nFld ]
aFile[ i , nFld ] := aRec[ nFld ]
ENDIF
NEXT nFld
NEXT nNew
RETURN NIL
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 48 guests