add a new text line to an existing file

BlitzMax Forums/BlitzMax Beginners Area/add a new text line to an existing file

hub(Posted 2007) [#1]
Hi
how to add a new text line to an existing file without delete the previous informations ? Test this :

OutFile = WriteFile( "MyTest.txt" )
WriteLine OutFile, "one string."
WriteLine OutFile, "another one."
CloseFile OutFile

OutFile = WriteFile( "MyTest.txt" )
WriteLine OutFile, "i want add this without delete the previous"
CloseFile OutFile


this produce this into the file :
i want add this without delete the previous

i want :
one string.
another one.
i want add this without delete the previous


Thanks


Gabriel(Posted 2007) [#2]
Use OpenFile instead of WriteFile.

You may also need SeekStream and StreamSize to set the file position to the end of the file.


HCow33(Posted 2007) [#3]
Local Stream:TStream = OpenStream(filename)
SeekStream(Stream, Stream.Size())
WriteLine(Stream, text)
CloseStream(Stream)