: : : : I have a file scan procedure that returns me a list of integer representing the position of all the times it found the word it was searching for. what i want to do is that base on that integer to extract the entire line where the word was found and copy it to another file.
: : : : for example
: : : : the house is blue.
: : : : the car is yellow.
: : : : the house is green.
: : : :
: : : : if i search for house it would return 2 integers giving me the position of both "house" what i would like is to extract does two lines and copy them to another file.
: : : :
: : : : any help will be appreciated. thank you
: : : :
: : : You can best load the entire file into a stringlist and use it to get the lines. A second stringlist can represent the destination file, and can later be saved onto the disk.
: : :
: : thanks.
: : I try that but the problem is that using stringlist is to slow thats why i was using the scanfile procedure that is really fast but it only returns the positon of every time the it finds a word that you are looking for. the thing is that i need to look in about 100 files (each containing about 1000+ lines) for each line that starts with the word ERROR. for example
: :
: : ERROR - this is a test
: :
: : so every line that starts with ERROR i need to put in another file.
: : i need something fast i was told that scanning was fast and it is the problem is getting the line out of the file.
: : if you can help i will really appreciated
: :
: The following get procedure is quite slow, but it's easy to program. You open the file as a file of char. Then seek() to the first position of the word error and start to copy it char for char to the other file, until you encounter the #13#10 line ending code. Then you seek() the next position, and start copying. Repeat this seek-copy procedure until all the ERROR-lines are copied.
: Another method, which involves 2 scans of each file is making a map of all the ERROR positions and of all the #13#10 positions. Then you can calculate the length of each ERROR line, and use untyped files and BlockRead()/BlockWrite() to perform the copying. It is more error-prone, but could be faster than the previous method.
:
thanks that worked just fine thanks again