Jump to content

Recommended Posts

Posted

Hello

I'm trying to read a .txt file and if the specific searchstring was found then it should be replaced but it doesn't work :/

What am I doing wrong below?

$text = "test1.txt"

$readtext = FileReadLine($text)

If StringInStr($readtext, "Hello") Then
    StringReplace($text,"Hello","Goodbye")
    MsgBox(1,"Status","Hello was found and has been replaced")
Else
    MsgBox(0,"Status","Hello wasn't found in test1.txt")
EndIf

Regards

Posted

First thing, you are trying to perform StringReplace() on $text, which should be $readtext.

Second, if you are expecting this to update your file, it won't. You need to find _ReplaceStringInFile in the User Defined Functions part of the help file.

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
×
×
  • Create New...