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 / save/read files

Author
Message
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 1st Jan 2004 02:39
Can anyone explain how to save data to, and read data from, files? I have had this program for ages but never really bothered to try and sort out the (very large) holes in my knowledge, but I can't really understand what it means in the help function.
I want to store and read two variables (this will increase later... probably); health# and score# to a file called "data.dat". How do I do this?

Am I the only one here who's really confused?
CarlTaylor
21
Years of Service
User Offline
Joined: 13th Jan 2003
Location: United States
Posted: 1st Jan 2004 04:54
Put the variables into an array and use the "Save Array" command:

Syntax
SAVE ARRAY Filename, Array Name(0)

and then use the "Load Array" command to get them back out.

(This is for DBP, i dunno which one you have.)

Don't leech graphics and code! Make your own or you'll never learn...
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 1st Jan 2004 12:08
Just in case...
DarkBASIC classic can use the
OPEN FILE
CLOSE FILE
READ/WRITE BYTE/WORD/LONG/etc. commands
The "/"s represent substitutes for commands ie: could be WRITE WORD

Juvenile Industries
Current Project: The First Room (FPS)
Soon to come:An rts, and a snowball fight game
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 1st Jan 2004 13:30
Attached is the code which I am using for writing data (at least I managed to figure this bit out). I decided to use a .txt file. I am using the data as a string. I need to find out how to read the data.

P.S. if I have done anything wrong please tell me.

Am I the only one here who's really confused?
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 1st Jan 2004 14:16
You could change your code to this.



You can also write floats to files so you could also do this, but it wouldn't be human-readable.



To load it for the first example do this



And for the second example.



dbpro : 2ghz p4m : 512mb : geforce 4 4200 go

Login to post a reply

Server time is: 2024-11-25 22:41:00
Your offset time is: 2024-11-25 22:41:00