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

Username:   Password: 
 RegisterRegister   
 saving to a file
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Insectoid




PostPosted: Mon Apr 28, 2008 6:45 pm   Post subject: saving to a file

My compsci class just finished doing imported files (xxx.IN) but I noticed that we didn't do exporting. I thought, That would be great for high scores and stuff! I can do things like 'get: filename, item' and I suppose that it's just a few more lines of code to save to that file! I also know how to save pictures to 'My Documents' or other such places, but not how to add text to a file remotely (as in another file doing it for me).

All of this is just a long-winded way of saying 'how do I make a High-Scores list?"
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: Mon Apr 28, 2008 7:17 pm   Post subject: Re: saving to a file

its a lot like getting info from a file, but you use "put" instead of "get"


code:

open : fnum, fname, put

put : fnum, info

close (fnum)


where info is whatever you want to go into the file.
Insectoid




PostPosted: Mon Apr 28, 2008 7:26 pm   Post subject: RE:saving to a file

Well, That certainly helps! (I assume 'fnum' is the variable name given to the file, and 'fname' is the actual file directory?) I can't quite remember...
TheGuardian001




PostPosted: Mon Apr 28, 2008 7:29 pm   Post subject: Re: saving to a file

Yes, fnum is an integer variable, and fname is the file you want to save to. if the file doesnt exist, turing will create it.
gitoxa




PostPosted: Mon Apr 28, 2008 7:33 pm   Post subject: Re: saving to a file

You can always using the turing help menu to find out more once you know the correct command.

And yes, 'fnum' refers to the number of the stream opened. Assigned to an int variable, will produce a value greater then 0 if it opens the file succesfully.

'fname' is the name of the file (including any extra directories).

Both are variables, so they aren't limited to those names. Wink
Insectoid




PostPosted: Mon Apr 28, 2008 8:01 pm   Post subject: RE:saving to a file

Unfortunately, the help menu does not work for me. It seems to want a web page which it cannot load, even when connected to the internet. When I took it to school on my thumb drive (To replace their crappy version) the same thing happens.

Thanks, you've helped a lot!
CodeMonkey2000




PostPosted: Mon Apr 28, 2008 8:38 pm   Post subject: RE:saving to a file

Next time please look at the turing walkthrugh before post. Thanks Very Happy
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  [ 7 Posts ]
Jump to:   


Style:  
Search: