Jump to content
Sign in to follow this  
soulhealer

a function to find a line contains text of "blablabla"

Recommended Posts

soulhealer

is there a function to find a line from a textfile that contains text of "blablabla"(for example) ?

thanks for anyhelp. :whistle:

Edited by soulhealer

Share this post


Link to post
Share on other sites
CodeMaster Rapture

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

Share this post


Link to post
Share on other sites
Valuater

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)


NEWHeader1.png

Share this post


Link to post
Share on other sites
rbhkamal

Try this:

Func fileHasString($P_Path , $P_text)
    Return StringInStr( FileRead( $P_Path , FileGetSize($P_Path) ) , $P_text  , 1 )
EndFunc

Edit: too late!

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Share this post


Link to post
Share on other sites
soulhealer

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

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.

EDIT: too late too :whistle:

Edited by soulhealer

Share this post


Link to post
Share on other sites
Valuater

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)


NEWHeader1.png

Share this post


Link to post
Share on other sites
soulhealer

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 :whistle:

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×