RESUME
- Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgResume
- Last revised: 2018-05-14
Error handling statement to resume execution after a jump to an error handler
Syntax
` Resume
`
Description
Resume is used in the traditional QB error handling mechanism within an error handler (called by On Error) to return execution to the line that caused the error. Usually this is used after the error has been handled gracefully in order to try the previously erroneous operation again with corrected data.
Resume resets the Err value to 0
Examples
start GeSHi
vb
'' Compile with -lang fblite or qb
#lang "fblite"
Dim As Single i, j
On Error Goto ErrHandler
i = 0
j = 1 / i ' this line causes a divide-by-zero error on the first try; execution jumps to ErrHandler label
Print j ' after the value of i is corrected, prints 0.5
End ' end the program so that execution does not fall through to the error handler again
ErrHandler:
i = 2
Resume ' execution jumps back to 'j = 1 / i' line, which does not cause an error this timeend GeSHi
Dialect Differences
- RESUME is not supported in the -lang fb dialect. Statements can be used in its function form to return an error code
start GeSHi
vb
If Open( "text" For Input As #1 ) <> 0 Then
Print "Unable to open file"
End Ifend GeSHi
Differences from QB
See also
ErrResume Next- Error Handling
Back to DocToc