neat way to append text to file
BlitzMax Forums/BlitzMax Beginners Area/neat way to append text to file
| ||
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 |
| ||
Local Stream:TStream = OpenStream("c:\myfile.txt") SeekStream(Stream, Stream.Size()) WriteLine(Stream, "My Line of Text ") CloseStream(Stream) FlushMem |
| ||
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 |
| ||
change If FileType("myfile.txt") = 0 Then CreateFile(filename) to If FileType(filename) = 0 Then CreateFile(filename) |
| ||
changed it! thanks perturbio. |
| ||
Thansks Perturbatio! |