Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Saving variables
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Task Bar




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Wed Sep 29, 2004 2:29 pm   Post subject: (No 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".
Delos




PostPosted: Wed Sep 29, 2004 5:33 pm   Post subject: (No 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!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: