Code archives/File Utilities/AddLineToFile
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Use it to keep a running record of game progress. | |||||
Function AddLineToFile(textline$,file$) mf3=WriteFile("tmp.txt") If FileType(file$)=0 Then Goto writelastline mf2=ReadFile(file$) Repeat w$=ReadLine(mf2) WriteLine(mf3,w$) Until Eof(mf2) CloseFile(mf2) .writelastline WriteLine(mf3,textline$) CloseFile(mf3) CopyFile "tmp.txt",file$ End Function |
Comments
| ||
This should be a lot quicker,since it jumps to the end of the file and appends a line to it, without having to copy the entire content. It also negates the reqwuirement for the rather unwieldy "Goto" and Label within a function :) |
Code Archives Forum