Jump to content

FileWrite


Scanzee
 Share

Recommended Posts

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

Link to comment
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.


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

Link to comment
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 :"> :"> :">


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

Link to comment
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
Link to comment
Share on other sites

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
Link to comment
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)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...