Hi guys,
I have a .txt file full of single line words, and phrases. For example, a .txt file with 20 lines, each line = 1 to 5 words.
I would like to send each line through some processing via a gosub routine until EOF.
Here is what I'm using:
;Read through file line by line
termfile = "c:\kde\searchterms.txt"
handle = FileOpen(termfile, "READ")
count = 0
While @TRUE ; Loop till break do us end
line = FileRead(handle)
If line == "*EOF*" Then Break
count = count + 1
term = StrCat("",line)
gosub process_term
EndWhile
FileClose(handle)
Everything works fine until the gosub process_term return which errors out at 'line=FileRead (handle)'. So when the gosub is returned for the next line in the file, it bombs. I'm thinking I need a for loop under "count = count + 1"?
How do I send each line from termfile down gosub process_term for processing, and then when EOF hits processing stops?
Hope this enough info.
Thanks!
ST
It is impossible to answer your question without knowing the exact error you are receiving and the content of your subroutine.
Thanks, this solved it for me:
filename = "c:\test\test.txt"
file = FileGet(filename)
file = StrReplace(file,@CRLF,@TAB)
llinecount = ItemCount(file,@TAB)
For ii = 1 To linecount
line = ItemExtract(ii,file,@TAB)
; You would do your stuff here
Next
Exit
I guess all's well that ends well.
Something involving a reference to sleeping dogs might be appropriate here.