Jump to content

Recommended Posts

Posted

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

Posted (edited)

  gav46 said:

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.
Posted

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

Posted

  gav46 said:

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...