Wiki source for KeyPgResume


Show raw source

{{fbdoc item="title" value="RESUME"}}----
Error handling statement to resume execution after a jump to an error handler

{{fbdoc item="syntax"}}##
**Resume**
##
{{fbdoc item="desc"}}
##**Resume**## is used in the traditional QB error handling mechanism within an error handler (called by ##[[KeyPgOnerror|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 ##[[KeyPgErr|Err]]## value to 0

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/error/resume.bas"}}%%(freebasic)
'' 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 time
%%

{{fbdoc item="lang"}}
- RESUME is not supported in the //[[CompilerOptlang|-lang fb]]// dialect. Statements can be used in its function form to return an error code
{{fbdoc item="filename" value="examples/manual/check/KeyPgResume_1.bas"}}%%(freebasic)
If Open( "text" For Input As #1 ) <> 0 Then
Print "Unable to open file"
End If
%%

{{fbdoc item="diff"}}
- Does not accept line numbers or labels
- Must compile with //[[CompilerOptex|-ex]]// or //[[CompilerOptexx|-exx]]// option

{{fbdoc item="see"}}
- ##[[KeyPgErr|Err]]##
- ##[[KeyPgResumenext|Resume Next]]##
- [[ProPgErrorHandling|Error Handling]]

{{fbdoc item="back" value="CatPgError|Error Handling Functions"}}
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode