Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / File command issue?

Author
Message
xSpadez
14
Years of Service
User Offline
Joined: 11th Apr 2012
Location: 127.0.0.1
Posted: 23rd Apr 2012 03:06
Hello,

Whilst reviewing my knowledge of the FILE commands and writing a small demo I just noticed (Or may have missed) that OPEN TO WRITE only works if the file DOESN'T exist?!?! In that case, how would you open an already created file (from the past) and write MORE data to it without overwriting the previous strings/data in the file?

Thanks,

xSpadez

xSpadez - Like a baws
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 23rd Apr 2012 12:34
As far as I'm aware this isn't possible with core DBP. You would have to read the original file into temporary variables, delete the original file and then write it from scratch with your amendments.


Previously TEH_CODERER.
Attila
FPSC Reloaded TGC Backer
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 23rd Apr 2012 13:06 Edited at: 23rd Apr 2012 13:14
DB does not provide an "open to append" command.

But you can open the 'old' file and although open the new file read the old file and write it the new one and then append your data.

a.e.

- Filename$ is the name of the existing file (mydata.dat)




Using the code code, you can easily create a function to append to a file
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Apr 2012 15:14
xSpadez
14
Years of Service
User Offline
Joined: 11th Apr 2012
Location: 127.0.0.1
Posted: 23rd Apr 2012 19:26
Quote: "... or you can use the free replacements in my plug-in set. They're faster too.
"


Ok I'll just go with that. Thanks!

Btw the reason was I am making a editor and if theres an error I had it write to a dump file :p


Thanks again

xSpadez - Like a baws

Login to post a reply

Server time is: 2026-07-10 18:55:55
Your offset time is: 2026-07-10 18:55:55