ERROR: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "The ERROR statement is used to simulate a program error or to troubleshoot error handling procedures. {{PageSyntax}} : ERROR {{Parameter|codeNumber%}} {{PageDescription}} * Can be used to test an error handling routine by simulating an error. * Error code 97 can be used to invoke the error handler for your own use, no real error in the program will trigger error 97. * Use error codes between 100 and 200 for custom program errors that will not be responded to...")
 
No edit summary
 
(3 intermediate revisions by one other user not shown)
Line 7: Line 7:


{{PageDescription}}
{{PageDescription}}
* Can be used to test an error handling routine by simulating an error.  
* Can be used to test an error handling routine by simulating an error.
* Error code 97 can be used to invoke the error handler for your own use, no real error in the program will trigger error 97.
* Error code 97 can be used to invoke the error handler for your own use, no real error in the program will trigger error 97.
* Use error codes between 100 and 200 for custom program errors that will not be responded to by QB64.  
* Use error codes between 100 and 200 for custom program errors that will not be responded to by QB64.




{{PageExamples}}
{{PageExamples}}
''Example:'' Creating custom error codes for a program that can be handled by an [[ON ERROR]] handling routine.
''Example:'' Creating custom error codes for a program that can be handled by an [[ON ERROR]] handling routine.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|ON ERROR}} {{Cl|GOTO}} handler
{{Cl|ON ERROR}} {{Cl|GOTO}} handler


Line 27: Line 27:
{{Cl|PRINT}} {{Cl|ERR}}, {{Cl|_ERRORLINE}}
{{Cl|PRINT}} {{Cl|ERR}}, {{Cl|_ERRORLINE}}
{{Cl|BEEP}}
{{Cl|BEEP}}
{{Cl|RESUME}} {{Cl|NEXT}} '' ''
{{Cl|RESUME}} {{Cl|NEXT}}
{{CodeEnd}}
{{CodeEnd}}
: '''Note: Don't use error codes under 97 or over 200 as QB64 may respond to those errors and interrupt the program.'''
: '''Note: Don't use error codes under 97 or over 200 as QB64 may respond to those errors and interrupt the program.'''
Line 33: Line 33:


{{PageSeeAlso}}
{{PageSeeAlso}}
*[[ON ERROR]]  
*[[ON ERROR]]
*[[ERR]], [[ERL]]
*[[ERR]], [[ERL]]
*[[_ERRORLINE]]  
*[[_ERRORLINE]]
*[[ERROR Codes]] (list)
*[[ERROR Codes]] (list)




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 01:34, 23 January 2023

The ERROR statement is used to simulate a program error or to troubleshoot error handling procedures.


Syntax

ERROR codeNumber%


Description

  • Can be used to test an error handling routine by simulating an error.
  • Error code 97 can be used to invoke the error handler for your own use, no real error in the program will trigger error 97.
  • Use error codes between 100 and 200 for custom program errors that will not be responded to by QB64.


Examples

Example: Creating custom error codes for a program that can be handled by an ON ERROR handling routine.

ON ERROR GOTO handler

IF x = 0 THEN ERROR 123
x = x + 1
IF x THEN ERROR 111

END


handler:
PRINT ERR, _ERRORLINE
BEEP
RESUME NEXT
Note: Don't use error codes under 97 or over 200 as QB64 may respond to those errors and interrupt the program.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link