Sign in to follow this  
Followers 0
Scanzee

FileWrite

8 posts in this topic

Is it possible that the text you write in an .txt file comes on the top of the file and not on the end?!

(Like FileWrite("...",1) does

Let me know..

and a second question if the previous prob. works:

Is it possible that you put a limit on a .txt file. So the file does't become so big.

Thanks for any help...

Share this post


Link to post
Share on other sites



Is it possible that the text you write in an .txt file comes on the top of the file and not on the end?!

(Like FileWrite("...",1) does

Let me know..

and a second question if the previous prob. works:

Is it possible that you put a limit on a .txt file. So the file does't become so big.

Thanks for any help...

FileWriteLine will do the first part of your question. I have not found an answer to the size limit.


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

What is the code of that because i tried a couple of time but it didn't work...

Share this post


Link to post
Share on other sites

What is the code of that because i tried a couple of time but it didn't work...

I am sorry I have just told you a lot of junk :"> :"> :">


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

What you could do to fix both your problems, is to open the file, read the text in it to memory (a variable), then write OVER the file what you want at the top, then write your file that you had in memory. And as for keeping your file a certain length. You can do that in a few ways, depending on what you concider as a "length" 100 lines, 10k. 20 Messages. But in any case, all you do is go through, read the file, and count. if you tell me what way you wish to count, i can help you in more detail. Hope i was of some help. :-)


Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

True - most languages has a seek function to seek in a location to append text, but Autoit do not but it is also a very slow method as disk speed can't compare with cpu, I would just loadin all text to do the changes and save the changed text as a new file, this also gives an option to do an undo etc. and all parametres of the text as amound of characters is easy to provide - just do it the simple way and do not think of autoit3 as just anouther language as it is not - it's a automation language with a lot of simplisities but cable on doing most tasks if one use intuition and some walk arounds...

kjactive B)

Edited by kjactive

Share this post


Link to post
Share on other sites

About 100 lines in a .txt file is enough... Thanks for all help...

Share this post


Link to post
Share on other sites

This should come close to what you want:

Local $File = 'C:\TheFile.txt'
Local $Data = 'This line will be added to the top of the file.' & @CRLF

; Add the data from the file
$Data = $Data & FileRead($File, FileGetSize($File)))

; Trim any data after the 100th line
Local $TrimPoint = StringInStr($Data, @CRLF, 0, 100)
If $TrimPoint Then $Data = StringLeft($Data, $TrimPoint + 1)

; Write the new data to the file
FileDelete($File)
FileWrite($File, $Data)

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