neat way to append text to file

BlitzMax Forums/BlitzMax Beginners Area/neat way to append text to file

Jay Kyburz(Posted 2005) [#1]
Hey All,

Does anybody know a neat way to append a line of text to a text file. I'm having a brain lock up and can't figure out a nice way.

ie

open a file
find the eof
writeline
close file


Perturbatio(Posted 2005) [#2]
Local Stream:TStream = OpenStream("c:\myfile.txt")
SeekStream(Stream, Stream.Size())
WriteLine(Stream, "My Line of Text ")
CloseStream(Stream)
FlushMem



bradford6(Posted 2005) [#3]
cool perturbio. here is a function from your code:

appendtext("myfile.txt","this is a new line!")
appendtext("myfile.txt","this, too, is a new line!")

Function appendtext:String(filename:String,text:String)
	If FileType(filename) = 0 Then CreateFile(filename)
	Local Stream:TStream = OpenStream(filename)
	SeekStream(Stream, Stream.Size())
	WriteLine(Stream, text)
	CloseStream(Stream)
	FlushMem
End Function



Perturbatio(Posted 2005) [#4]
change
	If FileType("myfile.txt") = 0 Then CreateFile(filename)

to
	If FileType(filename) = 0 Then CreateFile(filename)



bradford6(Posted 2005) [#5]
changed it! thanks perturbio.


Jay Kyburz(Posted 2005) [#6]
Thansks Perturbatio!