newbiescripter Posted February 27, 2008 Share Posted February 27, 2008 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 Link to comment Share on other sites More sharing options...
weaponx Posted February 27, 2008 Share Posted February 27, 2008 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. Link to comment Share on other sites More sharing options...
newbiescripter Posted February 27, 2008 Author Share Posted February 27, 2008 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now