Sign in to follow this  
Followers 0
erezlevi

erasing lines from end of file

5 posts in this topic

hi, all.

how can I erase lines from the end of file after opening it for edit:

$file=FileOpen  ("c:\0522554720.htm",1)

I want to erase lines from the end of the file.

Share this post


Link to post
Share on other sites



_FileReadtoArray

The for loop, and filewriteline.

But how do you not write the last lines? The secret is in the to of the for loop. see if you can work it out. Hint, expressions can be used... :)

Share this post


Link to post
Share on other sites

You could use _FileCountLines to get the number of the last line in the file and then use _FileWriteToLine without any text to delete the line without having to open the file.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

You could use _FileCountLines to get the number of the last line in the file and then use _FileWriteToLine without any text to delete the line without having to open the file.

Thanks for your responses,

I'v choose the :

$filechange=_FileWriteToLine("c:\0522554720.htm",85, "my replacement for line 85", 1)

it erases the part i don't need from previus action and replaces it with new data continuasly. instead of using "my r...." i will use an $i string that allways changes.

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