[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
QbasicFAQ_Errors
How do I trap an error?
Back to QBasic FAQ Main Page.
Trapping an error is not hard, but what you do can make it that way.
To trap an error, QB has added error trapping commands. Using these, a simple error trapping routine would be like this:
The above example is a simple yet easily implemented way of handling program errors.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
QbasicFAQ_Errors
How do I trap an error?
Back to QBasic FAQ Main Page.
Trapping an error is not hard, but what you do can make it that way.
To trap an error, QB has added error trapping commands. Using these, a simple error trapping routine would be like this:
ON ERROR GOSUB TrapIT ' Program goes here... ' Program messes up. (The user never does!).... ' A skip-to place that helps handle the return... END TrapIT: PRINT "A program error occurred!" PRINT "To continue Press [Enter]" PRINT "To abort press [Esc]" PRNIT "To quit now, press "Q" DO A$ = INKEY$ LOOP SELECT CASE UCASE$(A$) CASE "Q":END CASE CHR$(13):RESUME NEXT CASE CHR$(27):RESUME END SELECT
The above example is a simple yet easily implemented way of handling program errors.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
