ERR - mkilgore/QB64pe GitHub Wiki

The ERR function returns the last QBasic error code number.

Syntax

errorNum% = ERR

Description

  • If there is no error, the function returns 0
  • Can be used in an error handling routine to report the last error code number.

Examples

Example: Simulating an error to test a program error handler that looks for a "Subscript out of range" error.

IF...THEN x = 0 THEN ERROR 111  'simulate an error code that does not exist
x = x + 1
IF...THEN x THEN ERROR 9        'simulate array boundary being exceeded

END

handler:
PRINT ERR, _ERRORLINE
BEEP
IF...THEN ERR = 9 THEN
  PRINT "The program has encountered an error and needs to close! Press a key!"
  K$ = INPUT$(1)
  SYSTEM
END IF
RESUME NEXT               'RESUME can only be used in error handlers '' ''

See also


Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
⚠️ **GitHub.com Fallback** ⚠️