1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 13:50:36 +00:00
QB64-PE/internal/help/ERR.txt

46 lines
1.2 KiB
Plaintext
Raw Normal View History

2017-10-10 14:55:21 +00:00
The [[ERR]] function returns the last QBasic error code number.
{{PageSyntax}}
2017-10-10 14:55:21 +00:00
: {{Parameter|errorNum%}} = [[ERR]]
2017-10-10 14:55:21 +00:00
{{PageDescription}}
* If there is no error, the function returns 0
* Can be used in an error handling routine to report the last error code number.
2017-10-10 14:55:21 +00:00
{{PageExamples}}
2019-04-15 01:15:33 +00:00
''Example:'' Simulating an error to test a program error handler that looks for a "Subscript out of range" error.
{{CodeStart}} '' ''
{{Cl|ON ERROR}} {{Cl|GOTO}} handler
{{Cl|IF...THEN|IF}} x = 0 {{Cl|THEN}} {{Cl|ERROR}} 111 'simulate an error code that does not exist
x = x + 1
{{Cl|IF...THEN|IF}} x {{Cl|THEN}} {{Cl|ERROR}} 9 'simulate array boundary being exceeded
{{Cl|END}}
handler:
{{Cl|PRINT}} {{Cl|ERR}}, {{Cl|_ERRORLINE}}
{{Cl|BEEP}}
{{Cl|IF...THEN|IF}} {{Cl|ERR}} = 9 {{Cl|THEN}}
2019-04-15 01:15:33 +00:00
{{Cl|PRINT}} "The program has encountered an error and needs to close! Press a key!"
K$ = {{Cl|INPUT$}}(1)
{{Cl|SYSTEM}}
{{Cl|END IF}}
{{Cl|RESUME}} {{Cl|NEXT}} 'RESUME can only be used in error handlers '' ''
{{CodeEnd}}
2017-10-10 14:55:21 +00:00
{{PageSeeAlso}}
* [[ON ERROR]], [[RESUME]]
2017-10-10 14:55:21 +00:00
* [[ERL]]
* [[_ERRORLINE]], [[_INCLERRORLINE]], [[_INCLERRORFILE$]]
* [[ERROR]]
* [[ERROR Codes]]
2019-04-15 01:15:33 +00:00
{{PageNavigation}}
<