
-----------------------------------
Insectoid
Mon Apr 28, 2008 6:45 pm

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?"

-----------------------------------
TheGuardian001
Mon Apr 28, 2008 7:17 pm

Re: saving to a file
-----------------------------------
its a lot like getting info from a file, but you use "put" instead of "get"



open : fnum, fname, put

put : fnum, info

close (fnum)


where info is whatever you want to go into the file.

-----------------------------------
Insectoid
Mon Apr 28, 2008 7:26 pm

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
Mon Apr 28, 2008 7:29 pm

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
Mon Apr 28, 2008 7:33 pm

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
Mon Apr 28, 2008 8:01 pm

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
Mon Apr 28, 2008 8:38 pm

RE:saving to a file
-----------------------------------
Next time please look at the turing walkthrugh before post. Thanks :D
