'Opening a file and reading into a string is very quick, but then placing
'the values into a structure in the example below takes 16 seconds
'to process 8000 records.
'
'If the file is opened for random access and each record is just read
'it takes under 1-second. Is LSET CLIENT slow because of the MID$ ?
'the values into a structure in the example below takes 16 seconds
'to process 8000 records.
'
'If the file is opened for random access and each record is just read
'it takes under 1-second. Is LSET CLIENT slow because of the MID$ ?
Code:
TYPE ClientType Everything AS STRING * 203 END TYPE FUNCTION PBMAIN AS LONG LOCAL CLIENT AS ClientType LOCAL RecordNumber AS LONG LOCAL TotalRecords AS LONG LOCAL sData AS STRING OPEN "\grid\file101.dat" FOR BINARY AS #1 TotalRecords = LOF(1)\LEN(CLIENT) GET$ #1, LOF(1),sData CLOSE #1 FOR RecordNumber = 1 TO TotalRecords 'This takes 16 seconds for 8000 records LSET CLIENT = MID$(sData,(RecordNumber-1) *LEN(CLIENT)+1) NEXT OPEN "\grid\file101.dat" FOR RANDOM AS #1 LEN = LEN(CLIENT) 'under a second for 8000 records TotalRecords = LOF(1)\LEN(CLIENT) FOR RecordNumber = 1 TO TotalRecords GET #1,RecordNumber,CLIENT NEXT END FUNCTION
Comment