Jump to content
Sign in to follow this  
daxstec

How can i search a text file for a string

Recommended Posts

daxstec

Hi all,

I have the following problem, I need a function which helps me to operate on:

$file = FileRead("D:\Script\script.au3")

in order to find a given string in this file. How to do it as simple as possible ?

Thanks !

Share this post


Link to post
Share on other sites
daxstec

Thank you very much, I must think over how to make the documentation of AutoIt3 more easy in use and propagate great tool AutoIt3 which has ofcourse a negative sides but nothing is perfect.

Thank you once more !

Share this post


Link to post
Share on other sites
JohnWPB

This should do it:

$file = FileRead("D:\Script\script.au3")
$result = StringInStr($file, "String To Find")

if $result then
    MsgBox(0, "Found it", "Found it at character position: " & $result)
Else
    MsgBox(0, 'Not Found', "String Not Found")
EndIf

Share this post


Link to post
Share on other sites
JohnWPB

Guess I replied just as you saw the "Look in the help file" :)

Share this post


Link to post
Share on other sites
JohnOne

Thank you very much, I must think over how to make the documentation of AutoIt3 more easy in use and propagate great tool AutoIt3 which has ofcourse a negative sides but nothing is perfect.

Thank you once more !

Take a look at the link in my sig.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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  

×