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

Username:   Password: 
 RegisterRegister   
 I need help with File I/O
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
gafiga




PostPosted: Sun Jun 22, 2008 11:55 am   Post subject: I need help with File I/O

Iv been working on an RPG game and i was wondering if there is anyway i can use File I/O to save my stats and stuff, close the program, and be able to load them up when i play again. iv looked at the tutorials on File I/O but they dont really say anything about stuff like this...or im just not understanding them. anyone wanna help?
Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: Sun Jun 22, 2008 3:44 pm   Post subject: RE:I need help with File I/O

use file I/O to store your variables in a text file upon saving.

So when you load, after checking to see if file exists
assign the variables the value that is in the file.

That simple.
DemonWasp




PostPosted: Mon Jun 23, 2008 8:28 am   Post subject: RE:I need help with File I/O

You may also want to look into the Open / Save dialog boxes (yes, there's a Turing call to show those, and it's not terribly difficult). Those will let your user select where to put the save file.
PesticideUse




PostPosted: Tue Aug 26, 2008 5:36 pm   Post subject: Re: I need help with File I/O

hey, im making an RPG too and right now im having problems with my save load feature...
if you start a new game you can save as often as you want but once you load and go to save there is an error that says 'C:/"file.txt" is open and may not be open twice' so im thinking that the file stays open after i load, i closed the "stream number" or what ever but is there a way to close the actual file?
gitoxa




PostPosted: Wed Aug 27, 2008 2:35 am   Post subject: RE:I need help with File I/O

Closing the stream number is closing the file. The problem is more than likely that you're not actually closing it.
S_Grimm




PostPosted: Tue Sep 02, 2008 11:40 am   Post subject: RE:I need help with File I/O

It helps if after you "save" you close the file and eliminate any reference to it from your code : ie. if your txt file is called "savegame001.txt", once you close it, eliminate the variable by overwriting it (ie turn "savegame001" into "savegame002")
SNIPERDUDE




PostPosted: Tue Sep 02, 2008 7:06 pm   Post subject: RE:I need help with File I/O

^ That has nothing to do with it, just make sure you close the file after you send the information to the file.
S_Grimm




PostPosted: Wed Sep 03, 2008 10:08 am   Post subject: RE:I need help with File I/O

if you close it and eliminate it, then there is no chance that it can be reopened.
Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: Wed Sep 03, 2008 1:45 pm   Post subject: RE:I need help with File I/O

But there truly is no point to eliminating it - the programme only does what you programme it to do. If you close the file, it's not going to give you any error (relating to the file already being open).

I am not getting mad or anything, just making it less confusing for the noobs than it needs to be.
Insectoid




PostPosted: Wed Sep 03, 2008 1:52 pm   Post subject: RE:I need help with File I/O

I've noticed that when compiled, turing's file I/O doesn't always work right. My Database worked perfectly in source, but crashed due to trying to open a file already open when compiled.
SNIPERDUDE




PostPosted: Wed Sep 03, 2008 4:08 pm   Post subject: RE:I need help with File I/O

True say, I've had strange errors using their file I/O too.
Zeroth




PostPosted: Wed Sep 03, 2008 6:15 pm   Post subject: Re: I need help with File I/O

That sounds like a library/dll issue. Maybe the file reads aren't being compiled in, and so, it may expect the library/dll in a place different than it is?
SNIPERDUDE




PostPosted: Thu Sep 04, 2008 6:42 am   Post subject: RE:I need help with File I/O

Not sure, usually doesn't happen.
S_Grimm




PostPosted: Thu Sep 04, 2008 10:19 am   Post subject: RE:I need help with File I/O

after you open it, and try to save it tells you that the files is still open, rigth? Save the file with a different name, like i said before. then have the program "scan" for text files in the save directory and present you with the option to load or


have it promt you for the save game file name.
SNIPERDUDE




PostPosted: Thu Sep 04, 2008 1:28 pm   Post subject: RE:I need help with File I/O

typically doesn't happen. Rarely really.
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 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: