
-----------------------------------
FalconPAwnch
Thu Mar 13, 2008 11:36 pm

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.

-----------------------------------
HeavenAgain
Thu Mar 13, 2008 11:42 pm

RE:Error Check for reading from text files
-----------------------------------
        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
Thu Mar 13, 2008 11:47 pm

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.
