Sign in to follow this  
Followers 0
gav46

help to search file for text

4 posts in this topic

does AutoIT have a simple function to search a file for specific text (and return msg with result)?

Something like the dos findstr command.....

I have a log file (c:\Applog.txt) which appends with each successful application install. I want to check this file before running an app to see whether the user has already run this app in the past....

thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

does AutoIT have a simple function to search a file for specific text (and return msg with result)?

Something like the dos findstr command.....

I have a log file (c:\Applog.txt) which appends with each successful application install. I want to check this file before running an app to see whether the user has already run this app in the past....

thanks

<{POST_SNAPBACK}>

Something Like:

$TextFile="TextFile.txt"
$What2Find="One"
$Text=FileRead($TextFile,FileGetSize($TextFile))
$Pos=StringInStr($Text,$What2Find,1)
Select
Case $Pos=0
    MsgBox(0,"Not Found",$What2Find & " was not found in " & $TextFile)
Case Else
    MsgBox(0,"Not Found",$What2Find & " found in " & $TextFile & " at offset " & $Pos)
EndSelect

Just change "Textfile.txt" to the path of the textfile you want to search and "One" to what you want to find in the textfile.

Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

Thanks for that..... I changed the line

$Pos=StringInStr($Text,$What2Find,1)

to

$Pos=StringInStr($Text,$What2Find)

otherwise it only searched the first line in the file and not the whole document..

Great

Thanks again

Share this post


Link to post
Share on other sites

Thanks for that..... I changed the line

$Pos=StringInStr($Text,$What2Find,1)

to

$Pos=StringInStr($Text,$What2Find)

otherwise it only searched the first line in the file and not the whole document..

Great

Thanks again

<{POST_SNAPBACK}>

Your Welcome :whistle:

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

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  
Followers 0