[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
486 » Links » WxDevCpp » Apple » Rasmus Lerdorf » CCompile » device » register » CSharpandWindowsForms » J2ME » 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.

last edited (December 9, 2002) by KDivad Leahcim, Number of views: 3093, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Site Management by Lars Hagelin at Kontantkort.se.