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 / Writing and Reading saved variables(save files)?

Author
Message
Jjsaro
9
Years of Service
User Offline
Joined: 21st May 2014
Location:
Posted: 26th Jun 2014 15:47
I want to make a notepad/wordpad file that contains code to set all the variables for progress and level unlocks. I need to know how to write the code to the file and I need to know how to run the files code to set the variables when its requested by the owner.
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 26th Jun 2014 20:50 Edited at: 26th Jun 2014 21:01
Writing to and reading from files is fairly straightforward. The important thing is to make sure you load the data in the same order you saved it in.

Assuming you're using regular DBPro commands, begin with OPEN TO WRITE which opens a new file for saving info to...

Now all you have to do is decide what order to save everything in, and make sure your load routine does the same order.

When saving to the file:
WRITE FILE - writes an integer (whole) number/variable
WRITE FLOAT - writes a decimal number/variable
WRITE STRING - writes a string or string variable


When loading from file:
OPEN TO READ - opens a file
READ FILE - universal for reading into all variable types

When finished:
CLOSE FILE - self explanatory

That's about it for the basics, I think.
I can code a quick example using the different variable types if that would be helpful.

666GO†O666
pcRaider
16
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 27th Jun 2014 04:54
sample code



windowsXp

Login to post a reply

Server time is: 2024-03-29 11:45:49
Your offset time is: 2024-03-29 11:45:49