Chobyhy Posted August 23, 2007 Share Posted August 23, 2007 I'm trying to make a function where someone searches at least 1 word in the line, it will display the whole line. Example: Line1: Test asfa1515as fasdf125 Line2: asdf12 45478df1 1111 Is there a way if someone inputs "Test" into an inputbox for a search, that whole Line 1 gets displayed? I dont think StringInStr would work since that only returns the position. Link to comment Share on other sites More sharing options...
fu2m8 Posted August 23, 2007 Share Posted August 23, 2007 I'm trying to make a function where someone searches at least 1 word in the line, it will display the whole line. Example: Line1: Test asfa1515as fasdf125 Line2: asdf12 45478df1 1111 Is there a way if someone inputs "Test" into an inputbox for a search, that whole Line 1 gets displayed? I dont think StringInStr would work since that only returns the position. You could probably use something like _FileReadToArray with a loop to do what your after. #include <File.au3> Dim $lines $search = InputBox("Enter Search String", "Enter the string your looking for...") _FileReadToArray(@ScriptDir & "\testFile.txt", $lines) ;<-- needs a file called testFile.txt in the same directory as the script For $x = 1 To $lines[0] ;loops through each line in the text file If StringInStr($lines[$x], $search) Then ;reads each line of the file for the search MsgBox(64, "Match Found", "Found a match on line " & $x & ". The line is: " & @CRLF & $lines[$x]) ;prompt showing line number and full line EndIf Next 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