Writting files....plz Help !

BlitzPlus Forums/BlitzPlus Programming/Writting files....plz Help !

Crystal Noir(Posted 2003) [#1]
Hi all :)

I wonder how to write a file when it already exists ?

I have a file with some datas.So, I want to add informations without erase existing datas....I would like to add datas at the end of this file...

how to do this ?

Thank's in advance :)


Eikon(Posted 2003) [#2]
Your gonna need to ReadFile all the existing data into some variables. Next OpenFile and insert the old data along with any new stuff you want.


MutteringGoblin(Posted 2003) [#3]
Erm...

I haven't used Blitz for a while but that doesn't sound right to me. You should be able to just open the file with OpenFile and then find the end using SeekFile and FileSize.


soja(Posted 2003) [#4]
Can you not use SeekFile and Eof to move the file pointer to the end of the file, then use the file Write commands?


MutteringGoblin(Posted 2003) [#5]
Like I said my Blitz is a bit rusty but something like this should do it...

Local FileName$ = "whatever.txt"
Local File = OpenFile(FileName$)
If File
    SeekFile(File,FileSize(FileName$))
    WriteLine(File," Helloooo!")
    CloseFile(File)
EndIf




podperson(Posted 2003) [#6]
If you look in Code Archives / Miscellaneous, I've posted text and data utilities that should make life MUCH easier when trying to stick data in text files and/or retrieve it.


Crystal Noir(Posted 2003) [#7]
ok thank you very much :) thx all :)