[HELP] saving / loading system minor issue
Author |
Message |
tjmoore1993
![](http://compsci.ca/v3/uploads/user_avatars/8387623034a0f8ae34317b.gif)
|
Posted: Wed Apr 01, 2009 7:27 pm Post subject: [HELP] saving / loading system minor issue |
|
|
I'm making this game and I've stumbled across a problem because I want to make the program bullet-proof.
I've looked into the problem and I do not know how to code it.
What I want to do is when my program is loading a file and the file is there it loads, but of course I got this working.
The problem is when the file isn't there the program crashes. How would I make it so that the program gives some sort of an error
and says something like please relocate the file or make sure it is in the proper directory.
Turing: | elsif sav_option = "2" then
put "What is the name of your saved file?"
get file_name
file_name + = extension
location + = file_name
open : stream, location, get
loop
exit when eof (stream )
get : stream, char_name
get : stream, char_sex
get : stream, char_job
get : stream, a_point
get : stream, h_point
get : stream, m_point
get : stream, s_point
get : stream, d_point
get : stream, i_point
get : stream, l_point
end loop
close : stream
else
put "There is a problem locating the saved file."
end if |
Mod Edit: Remember to use syntax tags! Thanks code: | [syntax="turing"]Code Here[/syntax] |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
saltpro15
![](http://compsci.ca/v3/uploads/user_avatars/9776171634ced6278d14c2.png)
|
Posted: Wed Apr 01, 2009 7:30 pm Post subject: RE:[HELP] saving / loading system minor issue |
|
|
I don't think you can, Turing can't handle that kind of thing, if this is a class project your teacher should overlook minor errors like that |
|
|
|
|
![](images/spacer.gif) |
tjmoore1993
![](http://compsci.ca/v3/uploads/user_avatars/8387623034a0f8ae34317b.gif)
|
Posted: Wed Apr 01, 2009 7:42 pm Post subject: RE:[HELP] saving / loading system minor issue |
|
|
This is a personal project and I am trying to push turing to its limits. |
|
|
|
|
![](images/spacer.gif) |
Warchamp7
![](http://compsci.ca/v3/uploads/user_avatars/1427564341464495e84ae65.gif)
|
Posted: Wed Apr 01, 2009 8:02 pm Post subject: RE:[HELP] saving / loading system minor issue |
|
|
I'm not 100% on the matter but try this
Turing: |
elsif sav_option = "2" then
put "What is the name of your saved file?"
get file_name
file_name + = extension
location + = file_name
if stream > 0 then
open : stream, location, get
loop
exit when eof (stream )
get : stream, char_name
get : stream, char_sex
get : stream, char_job
get : stream, a_point
get : stream, h_point
get : stream, m_point
get : stream, s_point
get : stream, d_point
get : stream, i_point
get : stream, l_point
end loop
close : stream
else
put "There is a problem locating the saved file."
end if |
|
|
|
|
|
![](images/spacer.gif) |
Dusk Eagle
![](http://compsci.ca/v3/uploads/user_avatars/78727197549dd7290a342c.png)
|
Posted: Wed Apr 01, 2009 8:34 pm Post subject: Re: [HELP] saving / loading system minor issue |
|
|
You most definitely can do that!
Turing: |
loop
put "What is the name of your saved file?"
get file_name %In this example, the user must enter the extension themself.
exit when File.Exists(file_name )
put "Unavailable file. Please try again."
end loop
open: file, file_name
|
|
|
|
|
|
![](images/spacer.gif) |
tjmoore1993
![](http://compsci.ca/v3/uploads/user_avatars/8387623034a0f8ae34317b.gif)
|
Posted: Thu Apr 02, 2009 12:21 pm Post subject: RE:[HELP] saving / loading system minor issue |
|
|
Thanks for the help I came up with this solution.
Turing: | elsif sav_option = "2" then
loop
cls
put "What is the name of your saved file?"
get file_name
file_name + = extension
location + = file_name
exit
end loop
if File.Exists (location ) then
open : stream, location, get
loop
exit when eof (stream )
get : stream, char_name
get : stream, char_sex
get : stream, char_job
get : stream, char_level
get : stream, char_experience
get : stream, a_point
get : stream, h_point
get : stream, m_point
get : stream, s_point
get : stream, d_point
get : stream, i_point
get : stream, l_point
end loop
exit
end if
end if
end if
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
|
|