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

Username:   Password: 
 RegisterRegister   
 Error Check for reading from text files
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
FalconPAwnch




PostPosted: Thu Mar 13, 2008 11:36 pm   Post subject: Error Check for reading from text files

In the program I am making, the user inputs the filename of the text file that they would like to open. If this file does not exist, the program instantly crashes. Is it possible to make some sort of error check to see if the file exists or not before trying to open it? Thanks in advance.
Sponsor
Sponsor
Sponsor
sponsor
HeavenAgain




PostPosted: Thu Mar 13, 2008 11:42 pm   Post subject: RE:Error Check for reading from text files

code:
        var pathName : string
        var choice : string
        loop
            put "Enter file name to write results to" ..
            get pathName
            if File.Exists (pathName) then
                put "Overwrite ", pathName, "?" ..
                get choice
                exit when choice = "y"
            else
                exit
            end if
        end loop
from F10 turing help
FalconPAwnch




PostPosted: Thu Mar 13, 2008 11:47 pm   Post subject: Re: Error Check for reading from text files

That's from the F10 Turing help? Wow do I feel stupid. Thanks a bunch though dude, you may have just saved my life.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: