Sign in to follow this  
Followers 0
Hellfire

Replacing The Last Line Of A Txt File

5 posts in this topic

How can I replace the last line of the txt file to something else?

Example if text file looks like this.

1

2

3

I want to replace the 3 with 4

Share this post


Link to post
Share on other sites



with the count lines you might want to add +1 :think: or else you know it will write 4 next to 3

#include <File.au3>
_FileWriteToLine($file, _FileCountLines($file) + 1, "4")

Share this post


Link to post
Share on other sites

with the count lines you might want to add +1 :think: or else you know it will write 4 next to 3

#include <File.au3>
_FileWriteToLine($file, _FileCountLines($file) + 1, "4")
Except we have to add the 1 at the end of the argument list to replace 3 with 4 :(

#include <File.au3>
_FileWriteToLine($file, _FileCountLines($file) , "4",1)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

no :think: if you do a countlines its going to count 3 lines correct? but if he wants to add it on the last line (line 4) when it does the countilnes its goign to count 3. THus when he does the write to the line its going to write it on line 3 not line 4

edit: read the topic wrong thoguht he wanted to write to last line :(

Edited by thatsgreat2345

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