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.

Newcomers DBPro Corner / adding data to existing files

Author
Message
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 22nd Oct 2005 13:18
using dbpro. I am trying to open a file and add datat to it.
the program was going to be used to keep track of a work schedule.
so each day i could run it andd the hours i worked and it would save them to the file.
at the end of the week i want to be able to open the text file and see the hours for each day.
however the file must not exist to be able to
open to write.

i have tried to use the read file command
and then delete the file. then accept user input stor it in a variable then writting a file and trying to add the variable but you cannot use string witht hte write file command as far as i can tell. i have tryed to make a temporary folder but the peoblem still keeps me from adding data to the currently existing data i would appreciate some help. thank you for your time sorry for the long post i like to be explanitory

A child's dream never dies.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 22nd Oct 2005 21:22 Edited at: 22nd Oct 2005 21:31
That's one of the annoyances that I talked about in suggestions for 6.0... I wanted TGC to add the ability to read/write to a file without destroying it first... that promptly got shot down as a stupid idea because Darkbasic has that ability in memblocks... go figure.

http://forum.thegamecreators.com/?m=forum_view&b=1&t=61710&p=4

If your talking about strings it's best to just open two files at the same time... one to read from the first file and one to write the second file. Read from the original data and write what was read to the second file... when it gets to the end add what you want to the second file and close them both. Delete the original and rename the new file the original name.

I'm experimenting with memblocks (which is what several have told me will do what we want)... but I have yet to see the ability to write a string to memblocks. I suspect that a string has to be converted to bytes then written to a memblock... which is just as annoying as the inability to write files without destroying them first.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Oct 2005 05:35
All you need to do is read all the lines into a string array from the file and add the required extra lines to the end of the array.

Delete the file on disk, create the file again and write out the contents of the array to it.

TDK_Man

smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 23rd Oct 2005 10:03
thanks for the input guys. sure is alot or work to add datat to a file lol.

A child's dream never dies.

Login to post a reply

Server time is: 2024-09-24 07:33:58
Your offset time is: 2024-09-24 07:33:58