I just put this script together that will search the file for a string then write that line plus the next 8 lines to a file. (These 9 line have totals on them.) Is there a way to continue searching the file for the same string and if it finds the string again, write the line to another file. (This file will sometimes have this string twice.)
(Once these file are written the data will always be in the same place and I can pull the data.)
Thanks again
While findfirst "c:\test\test.DAT"
fopen 0 $filespec READ TEXT
while not feof 0
fgets 0 Code
termmsg "%s `r`n" code
if strfind Code "TOTALS FOR THIS FILE"
fopen 1 "C:\test\New File with string.txt" CREATE TEXT
fputs 1 code
fgets 0 Code
fputs 1 code
fgets 0 Code
fputs 1 code
fgets 0 Code
fputs 1 code
fgets 0 Code
fputs 1 code
fgets 0 Code
fputs 1 code
fgets 0 Code
fputs 1 code
fgets 0 Code
fputs 1 code
fgets 0 Code
fputs 1 code
fclose 1
Else
Goto end
EndIf
EndWhile
fclose 0
EndWhile
end:
PWexit
EndProc
Are you looking just to match the first string you are looking for? If so, save that to another string and then you can use the strfind command to search for that string in each line you read from then on.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.