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 / Saving and loading #'s and $'s

Author
Message
RoyalBlood
15
Years of Service
User Offline
Joined: 8th Apr 2009
Location: Stuck in this box!
Posted: 16th May 2009 02:52 Edited at: 16th May 2009 02:58
Hey guys, I'm doing a score based Trivia game in which I want you to be able to save your prfile name, your score, and what question youwere on, then reload them, and return to the question you were on last later. I know there's some save and load file commands, but I have no idea how to use them. Example would be greatly apreciated, thanks.

AMPConcepts.webs.com
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 16th May 2009 04:27
Here's a little example of writing strings and integers to a file, then opening the file and reading the data:



i like orange
RoyalBlood
15
Years of Service
User Offline
Joined: 8th Apr 2009
Location: Stuck in this box!
Posted: 16th May 2009 05:52
This is what I'm using:



AMPConcepts.webs.com
RoyalBlood
15
Years of Service
User Offline
Joined: 8th Apr 2009
Location: Stuck in this box!
Posted: 16th May 2009 06:15
Problem. When I use this function,
, it's creating the file, but when I open the .txt it's blank...

AMPConcepts.webs.com
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 16th May 2009 06:21 Edited at: 16th May 2009 06:22
Are your variables global, and do they have any values in them? If not then they would all be empty whenever the function is run, and nothing would be written to the file.

<-- Spell based team dueling game!
RoyalBlood
15
Years of Service
User Offline
Joined: 8th Apr 2009
Location: Stuck in this box!
Posted: 16th May 2009 06:25
Here's the entire program:



Right now, question 1 and 2 are just test subjects, q1 sets the variables then goes to the SaveGame function...Then I exit the game and check the .txt which is blank...

AMPConcepts.webs.com
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th May 2009 10:48
As Sixty Squares suggested, your variables are not global and hence would read as "" and 0 in the save function, thus writing a few null characters (ascii code 0) to the file, which displays as nothing in notepad.

Slap in

somewhere at the beginning of your code and you should be all set

RoyalBlood
15
Years of Service
User Offline
Joined: 8th Apr 2009
Location: Stuck in this box!
Posted: 16th May 2009 20:05
Thanks.

AMPConcepts.webs.com

Login to post a reply

Server time is: 2024-11-24 06:44:47
Your offset time is: 2024-11-24 06:44:47