bobheart Posted June 26, 2004 Share Posted June 26, 2004 I want to find is a file name is in a txt file but not sure how to read a file ? $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached While 1 $chars = FileRead($file, 1) If @error = -1 Then ExitLoop MsgBox(0, "Char read:", $chars) Wend FileClose($file) I don't want to read it one line at a time I want to see if a line is in that file . the line "bob.txt" is in a myfile.txt . Link to comment Share on other sites More sharing options...
BornExtreme Posted June 26, 2004 Share Posted June 26, 2004 i didnt realy understand what you mean?? are you looking for a line: bob.txt ? if yes why not to use loop and check every line? Link to comment Share on other sites More sharing options...
bobheart Posted June 26, 2004 Author Share Posted June 26, 2004 Yes the txt file is almost 3 mb so I don't want to look thur it so how would I use a loop to find bob.txt in a txt file or if it is in there . Link to comment Share on other sites More sharing options...
Developers Jos Posted June 26, 2004 Developers Share Posted June 26, 2004 $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached While 1 $chars = FileRead($file) If @error = -1 Then ExitLoop if stringinstr($char,"bob.txt") then MsgBox(0, "Char read:", $chars) Wend FileClose($file) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
bobheart Posted June 26, 2004 Author Share Posted June 26, 2004 Got this $chars = FileRead($file) $chars = ^ ERROR Error: Incorrect number of parameters in function call. Link to comment Share on other sites More sharing options...
Developers Jos Posted June 26, 2004 Developers Share Posted June 26, 2004 didn't test it... change it to FileReadLine SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now