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 / Load data from file

Author
Message
Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 15th Aug 2008 03:34 Edited at: 15th Aug 2008 03:37
I'm able to save a variable in a file...



It creates a file in that directory, but when I try to load the value with this...



... it doesn't work. Either my save function isn't saving the score value, or my load function isn't setting score to the saved value. I've used those two code snippets to save a score at the close of a program and load it again when the same program reopens. This time, I'm saving a score at the end of one program, closing that program, loading a different program, and trying to load the score value.

I don't have anything misspelled in the code. The functions are called correctly in the code. I can't wrap my head around why it works when saving and loading the same file within one program and why it doesn't work when saving in one program and loading in another.
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 15th Aug 2008 04:44
save function

read function


LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 15th Aug 2008 04:50
Two things you need to do:
1. Declare score as a global variable near the beginning of your code.
2. Have the 'getscore()' function return the score value
(i.e. endfunction score)

LB

Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 15th Aug 2008 05:06
Thanks guys, clarified some things for me. I missed both those when copying the functions from the old program.

Login to post a reply

Server time is: 2024-11-24 23:06:58
Your offset time is: 2024-11-24 23:06:58