soulhealer Posted October 30, 2006 Share Posted October 30, 2006 (edited) is there a function to find a line from a textfile that contains text of "blablabla"(for example) ? thanks for anyhelp. Edited October 30, 2006 by soulhealer Link to comment Share on other sites More sharing options...
CodeMaster Rapture Posted October 30, 2006 Share Posted October 30, 2006 Take a look at the File Manipulation functions in the helpfiles. Also, I'm sure a quick search on the forums could do you some good. -CMR Link to comment Share on other sites More sharing options...
Valuater Posted October 30, 2006 Share Posted October 30, 2006 maybe... #include <file.au3> $File_Name = "text.txt" $Find = "my text to find" Dim $aRecords If Not _FileReadToArray($File_Name, $aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] if StringInStr($aRecords[$x], $Find) Then Msgbox(0,'Record:' & $x, $aRecords[$x]) Next 8) Link to comment Share on other sites More sharing options...
rbhkamal Posted October 30, 2006 Share Posted October 30, 2006 (edited) Try this: Func fileHasString($P_Path , $P_text) Return StringInStr( FileRead( $P_Path , FileGetSize($P_Path) ) , $P_text , 1 ) EndFunc Edit: too late! Edited October 30, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
soulhealer Posted October 30, 2006 Author Share Posted October 30, 2006 (edited) Take a look at the File Manipulation functions in the helpfiles. Also, I'm sure a quick search on the forums could do you some good.-CMRi found only, FileReadLine function. which it's only to find a line according to a defined line number. what i want, is a function to search a string, and then returns the line number as a result.EDIT: too late too Edited October 30, 2006 by soulhealer Link to comment Share on other sites More sharing options...
Valuater Posted October 30, 2006 Share Posted October 30, 2006 i found only, FileReadLine function. which it's only to find a line according to a defined line number. what i want, is a function to search a string, and then returns the line number as a result.while rbhkamal's is good... very good!mine will show the line #8) Link to comment Share on other sites More sharing options...
soulhealer Posted October 30, 2006 Author Share Posted October 30, 2006 while rbhkamal's is good... very good!mine will show the line #8)Thanks to both rbhkamal and Valuater. Both of your inputs are exactly what I needed. Now the script is working perfectly 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