Sign in to follow this  
Followers 0
newbiescripter

StringReplace() error.. How to fix it?

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

yes it should update the file so when you open it up the new word is there insted.. I'll try the _ReplaceStringInFile and see if it works :)

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