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

Username:   Password: 
 RegisterRegister   
 [HELP] saving / loading system minor issue
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tjmoore1993




PostPosted: 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 Smile
code:
[syntax="turing"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
saltpro15




PostPosted: 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
tjmoore1993




PostPosted: 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.
Warchamp7




PostPosted: 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
Dusk Eagle




PostPosted: 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
tjmoore1993




PostPosted: 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
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  [ 6 Posts ]
Jump to:   


Style:  
Search: