Cap0 Posted February 3, 2007 Share Posted February 3, 2007 how would i do filewrite and stringreplace? if(stringinstr($params[4],"/nick\")) Then $read = FileRead("file.txt",FileGetSize("file.txt")) FileWrite("reply.txt",StringReplace($read,"xx",xx)) Endif i put this at the start of the script but it writes a lot of times.. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 3, 2007 Developers Share Posted February 3, 2007 how would i do filewrite and stringreplace? if(stringinstr($params[4],"/nick\")) Then $read = FileRead("file.txt",FileGetSize("file.txt")) FileWrite("reply.txt",StringReplace($read,"xx",xx)) Endif i put this at the start of the script but it writes a lot of times..It will append it to the end of the file in this way. You need to delete file "file.txt" before doing the FileWrite() SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Cap0 Posted February 4, 2007 Author Share Posted February 4, 2007 (edited) Still having trouble if(stringinstr($fileread,"xx")) Then Filedelete("re.txt") FileWrite("re.txt",StringReplace($fileread,"xx","yy")) Endif it doesn't replace Edited February 4, 2007 by Cap0 Link to comment Share on other sites More sharing options...
Cap0 Posted February 5, 2007 Author Share Posted February 5, 2007 bump Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 5, 2007 Moderators Share Posted February 5, 2007 bumpHow about providing a real example... like the rest of $fileread. I'm amazed at how little those that ask questions want to provide those of us that generally answer them sometimes. The endless bumps, or un-answered questions stem from lack of information generally. $hFileName = "FulPathToFile\FileName.txt" $sString = FileRead($hFileName) If StringInString($sString, 'xyz') Then FileClose(FileOpen($hFileName, 2)) FileWrite($hFileName, StringReplace($sString, 'xyz', 'abc')) EndIf Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
/dev/null Posted February 5, 2007 Share Posted February 5, 2007 how would i do filewrite and stringreplace? if(stringinstr($params[4],"/nick\")) Then $read = FileRead("file.txt",FileGetSize("file.txt")) FileWrite("reply.txt",StringReplace($read,"xx",xx)) Endif i put this at the start of the script but it writes a lot of times.. just use _ReplaceStringInFile() __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Cap0 Posted February 5, 2007 Author Share Posted February 5, 2007 How about providing a real example... like the rest of $fileread. $read = FileRead("file.txt",FileGetSize("file.txt")) as posted above in my first post.. thanks anyway, but i've found an easier solution. _ReplaceStringInFile(); 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