>Who can offer the most efficient (i.e. fastest) code to accomplish the following?
>
>I need to search 3,000 ascii text files spread among approximately 20 sub-dirs. The files might contain 200-300 lines, bu I only need to search the first 7 lines of each file for a short keyword that the user will enter into a textbox. I report all matches into a listbox.
>
>My current method opens the file for an ascii read, then "for x= 1 to 7" and use the ATC() function to look for a match on each read line. It works, but it's kinda slow, just becuase there are so many files.
>
>I will post my code when I get to work on Monday, and you can critique it.
>
>Thanks.
If you use FileToStr(), this will read the entire file into memory, and indeed be slow, since you need only the first 7 lines. For fast access, you should use LLFF, something like this:
MyFile = "SomeFile.txt"
FileHandle = fopen(MyFile)
for LineNumber = 1 to 7
Line = fgets(FileHandle)
next
fclose(FileHandle)
HTH,
Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)