Insert a line into text file
BlitzMax Forums/BlitzMax Beginners Area/Insert a line into text file
| ||
This is really annoying me. Should be simple. Basically, I'm trying to insert a line to a test file... myfile:TStream=WriteStream("test.txt") If WriteLine(myfile,"Hello") Print "Hello successful!" If WriteLine(myfile,"World") Print "World successful!" CloseStream(myfile) myfile1:TStream=OpenStream("test.txt") ReadLine(myfile1) If WriteLine(myfile1,"AGAIN") Print "AGAIN successful" CloseStream(myfile1) myfile2:TStream=ReadStream("test.txt") While Not Eof(myfile2) Print ReadLine(myfile2) Wend CloseStream(myfile2) <edit> P.s. tried simple writefile/openfile/readfile. I just can't get Openstream/file to read and write. Seems to only allow one of them. |
| ||
Tonyg, Have you tried looking at the seekstream, streampos functions? |
| ||
I have, and I have just found one of my own posts suggesting it to somebody else. I may well be trying to forget about this post in a few minutes but I still won't know why I need to seekstream. <edit> Hmmm, it's still a case of inserting a line. My guess is I will have to read and write each line. Maybe I did consider seekstream. It will only allow me to write to a certain position in the file. However, if that position is occupied it will overwrte that line. Without rewriting the while file I can't see how to insert. (which makes sense of course). |