Computer Science Canada

Saving variables

Author:  Task Bar [ Wed Sep 29, 2004 2:05 pm ]
Post subject:  Saving variables

hello, I need help with saving variables after closing the program. I want to store the variables in a txt file and recall them the next time I runt he program again. So if I input a name and then exit the program and run it again turing will put the name without asking me to input it again.

Author:  wtd [ Wed Sep 29, 2004 2:29 pm ]
Post subject: 

Your basic approach is going to be to test for the existence of a file (let's call it "name.dat"). If it exists, then you've saved the variable, and you can retrieve its value from the file.

If not, you just prompt for the name nomally, then open name.dat and write the name to it.

Turing may have facilities for doing this already. Look for "serialization".

Author:  Delos [ Wed Sep 29, 2004 5:33 pm ]
Post subject: 

You'll need these:

Basic file manipulation by Dan
Extended file manipulation by Delta

And this is a good example of it in use.
High Scores by Dan

Really, these Tutorials are amazing you know...so much there!


: