Sign in to follow this  
Followers 0
Cap0

filewrite and stringreplace

7 posts in this topic

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..

Share this post


Link to post
Share on other sites



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()

:)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Cap0

Share this post


Link to post
Share on other sites

bump

How 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

[center]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.[/center]

Share this post


Link to post
Share on other sites

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 *

Share this post


Link to post
Share on other sites

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();

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