clear file to write to

BlitzPlus Forums/BlitzPlus Programming/clear file to write to

Paulo(Posted 2004) [#1]
Suppose I was working away with my B+ app and decided to save the 4 lines of text I'd written, (using the Writeline command) Then at a later session, come back open the file and decide that all I needed was line 1 to say something else and decided to delete lines 2,3 and 4 - then save the file again. Next time I open it up, all 4 lines are back but line 1 is updated. How do I clear the file of any information before I write over it? Any insight on how to do this would be greatly appreciated, but please bear in mind Im quite new at this and a lot of the tech talk goes way over my head.


Rimmsy(Posted 2004) [#2]
f=writefile("the file.txt")


Paulo(Posted 2004) [#3]
yeah I know how to use that command, thats what Im using.
I'll try and be clearer...

Ive written an app. The app lets you save files, which are basically texts files. Ive got no problem with reading and writing to the file, but what I guess Im asking is can a file that youve written to once be somehow reset or cleared before writing to again. ie, save a load of blank space first? or something. :)


Rimmsy(Posted 2004) [#4]
Hmmm, you can use seekfile to position yourself at any point in the file. and filepos to find out where you currently are. Look at the help files for more information.

openFile opens a file ready to be updated or appended.

WriteFile, if used with an existing file opens and clears everything in it for you.


Paulo(Posted 2004) [#5]
Thanks okay I'll try that, I did wonder cus it seems that all the write and read commands say "prepares a file to be written to etc" .. no problem, I'll give it a try ;)