Kogmedia Posted April 29, 2007 Share Posted April 29, 2007 (edited) Hello everyone, I haven't been programing with autoit for very long. I have a problem and i can understand how I can work around it. I want to search a txt file, and search for a specific word and return all the results but my problem keeps on giving me the first one it found? Thanks, Keith Heres my code. #Include<Array.au3> #include <file.au3> Dim $pricehistory,$found $filename = "pricehistory.txt" $apptile = "Search!" $Input = InputBox("Price History Search", "Find?") If @error Then Exit If Not _FileReadToArray($filename,$pricehistory) Then MsgBox(4096,$apptitle, "Error reading watchlist:" & @error) Exit EndIf For $x = 1 to $pricehistory[0] $found = _ArraySearch ($pricehistory, $Input, 0, 0, 0, True) MsgBox(0,"Found",$found) Next Edited April 29, 2007 by Kogmedia [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search Link to comment Share on other sites More sharing options...
MHz Posted April 29, 2007 Share Posted April 29, 2007 ArraySearch() is not suitable for each line AFAIK as it will search the whole array at once. So use StringInStr(). For $x = 1 to $pricehistory[0] If StringInStr($pricehistory[$x], $Input) Then MsgBox(0,"Found", $Input) EndIf Next Link to comment Share on other sites More sharing options...
Zedna Posted April 29, 2007 Share Posted April 29, 2007 #Include<Array.au3> #include <file.au3> Dim $pricehistory,$found $filename = "pricehistory.txt" $apptitle = "Search!" $Input = InputBox("Price History Search", "Find?") If @error Then Exit If Not _FileReadToArray($filename,$pricehistory) Then MsgBox(4096,$apptitle, "Error reading watchlist:" & @error) Exit EndIf $found = _ArraySearch ($pricehistory, $Input, 0, 0, 0, True) MsgBox(0,"Found",$found) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
martin Posted April 29, 2007 Share Posted April 29, 2007 (edited) Hello everyone, I haven't been programing with autoit for very long. I have a problem and i can understand how I can work around it. I want to search a txt file, and search for a specific word and return all the results but my problem keeps on giving me the first one it found? Thanks, Keith Heres my code. #Include<Array.au3> #include <file.au3> Dim $pricehistory,$found $filename = "pricehistory.txt" $apptile = "Search!" $Input = InputBox("Price History Search", "Find?") If @error Then Exit If Not _FileReadToArray($filename,$pricehistory) Then MsgBox(4096,$apptitle, "Error reading watchlist:" & @error) Exit EndIf For $x = 1 to $pricehistory[0] $found = _ArraySearch ($pricehistory, $Input, 0, 0, 0, True) MsgBox(0,"Found",$found) Next Edit: changed For next to while wend Edited April 29, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Kogmedia Posted April 29, 2007 Author Share Posted April 29, 2007 Thanks! [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search 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