James Maeding
2003-07-17 17:49:38 UTC
Hi there,
I have a prog that looks in a folder, gets a list of files and reads the data from the files.
The text files are formatted almost exactly like .ini files.
Right now, the code from my function to get the data looks like this:
(setq FilSys (vlax-create-object "Scripting.FileSystemObject")
FilObj (vlax-invoke FilSys "GetFile" FilPth)
OpnFil (vlax-invoke FilObj "OpenAsTextStream" 1 0)
)
(while (= (vlax-get OpnFil "AtEndOfStream") 0)
(setq RetVal (cons (vlax-invoke OpnFil "ReadLine") RetVal))
)
You can see that I am using the scripting FSO to get at the file.
This works dependably and smoothly, but it is too slow.
It takes about .03 seconds to read a file.
With 300 files, this takes 9 seconds, way too slow.
I am wondering what options I have to speed things up.
Here is what I have thought of so far:
1) Make a DLL with VB that uses windows API functions to generate an array of strings from a text file. Then convert to
a list of strings.
2) Convert to using binary files for data, I would need to write DLL's in VB to do this (I think its possible). Convert
to list of strings...
3) Convert to using a database, instead of individual text files. This is not desirable.
4) Keep a list of data and only grab data from files that have changed since last "reading".
Anyone out there written an app that desperately needed to read lots of files fast?
thanks
James Maeding
Civil Engineer/Programmer
I have a prog that looks in a folder, gets a list of files and reads the data from the files.
The text files are formatted almost exactly like .ini files.
Right now, the code from my function to get the data looks like this:
(setq FilSys (vlax-create-object "Scripting.FileSystemObject")
FilObj (vlax-invoke FilSys "GetFile" FilPth)
OpnFil (vlax-invoke FilObj "OpenAsTextStream" 1 0)
)
(while (= (vlax-get OpnFil "AtEndOfStream") 0)
(setq RetVal (cons (vlax-invoke OpnFil "ReadLine") RetVal))
)
You can see that I am using the scripting FSO to get at the file.
This works dependably and smoothly, but it is too slow.
It takes about .03 seconds to read a file.
With 300 files, this takes 9 seconds, way too slow.
I am wondering what options I have to speed things up.
Here is what I have thought of so far:
1) Make a DLL with VB that uses windows API functions to generate an array of strings from a text file. Then convert to
a list of strings.
2) Convert to using binary files for data, I would need to write DLL's in VB to do this (I think its possible). Convert
to list of strings...
3) Convert to using a database, instead of individual text files. This is not desirable.
4) Keep a list of data and only grab data from files that have changed since last "reading".
Anyone out there written an app that desperately needed to read lots of files fast?
thanks
James Maeding
Civil Engineer/Programmer