![]() |
Error meesages - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html) +--- Thread: Error meesages (/thread-45.html) Pages:
1
2
|
Error meesages - somekid - 10-23-2002 in one of my programs, the user is asked to enter a file name and if they enter a name that does not exist the program exists and goes to the error screen in qbasic... Is it possible to over-ride that function and create error messages within the program that displays the closest matching filename and asks the user if they would like to open that instead?! :o Error meesages - red_Marvin - 10-23-2002 It's possible to do that with ON ERROR -Read about ON ERROR... You could always use some kind of trap - Sumo Jo - 10-24-2002 You could use if/then to make sure the file inputted is real, if it wasn't then you could print something out to the screen saying that the file they entered wasn't correct, try again. Error trapping, it makes the program tell the user something is wrong before the computer does. :bounce: Error meesages - somekid - 10-24-2002 how would i go about using the ON ERROR GOTO command? :???: i have absolutely no experience with error trapping what-so-ever... Error meesages - BlueKeyboard - 10-24-2002 Like this: Code: ON ERROR GOTO ErrorHandler ![]() Error meesages - Neo - 10-28-2002 Very good, however, don't overuse the ON ERROR commands, it makes your code quite slow... if statements for error trapping - somekid - 10-30-2002 what would i have to do if i wanted it to create a new file if the filename was not found using the same name as the file that was not found :???: ? i am assuming you would use an if command? thanks for the help! :lol: Error meesages - BlueKeyboard - 10-30-2002 You mean, if the file which the user entered is not found, the file should be created?, if so: Code: ON ERROR GOTO ErrorHandler If the file was not found, it prints out "File not found.", "Creating file: Somefile" Then it creates the file, and tries to reopen the file again, using RESUME. RESUME resumes the code line where the error occured. Error meesages - somekid - 10-30-2002 ok, i used the code you suggested and now it creates the new file! :rotfl: however, a new problem has popped up. it creates the file, then it opens the file and for some reason it goes to the errorhandler and freezes there. here is the sub where the problem occurs: Code: SUB SELECTSTUDENT i also modified the error handler to comply with my requirements: Code: ERRORHANDLER: Error meesages - BlueKeyboard - 10-30-2002 Exactly what line causes the problem?. |