From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- helpcontent2/source/text/sbasic/shared/Resume.xhp | 77 +++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 helpcontent2/source/text/sbasic/shared/Resume.xhp (limited to 'helpcontent2/source/text/sbasic/shared/Resume.xhp') diff --git a/helpcontent2/source/text/sbasic/shared/Resume.xhp b/helpcontent2/source/text/sbasic/shared/Resume.xhp new file mode 100644 index 000000000..fa9e60dcc --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/Resume.xhp @@ -0,0 +1,77 @@ + + + + + + Resume Statement + /text/sbasic/shared/Resume.xhp + + + + + Resume statement + +
+

Resume Statement

+ Resets error information and indicates what to execute next. +
+ + Resume Statement diagram + + Resume [ [0] | label | Next ] + + + 0: Resets error information and re-executes the instruction that caused the error. 0 is optional. + label: Resets error information and resumes execution at the specified label of the current subroutine. + Next: Resets error information and executes the instruction following the one that caused the error. + Error information is built with Erl, Err and Error$ functions. + + Erl: Module line number where error occurs. + Err: Error number. + Error[$]: Error description. + + Using Resume to reset error information prevents the propagation of the handled condition to calling routines. + + +

Examples:

+ Typical error handling routines are: alerting the user, fixing the error, logging error information or re-throwing custom errors that provide explanations with resolution instructions. Use Resume label when requiring such mechanisms. + + Sub Error_Handling + try: On Error GoTo catch + ' routine code goes here + Error 91 ' example error + finally: + ' routine cleanup code goes here + Exit Sub + catch: + Print Erl, Err, Error$ + Resume finally + End Sub ' Error_Handling + + Use Resume Next, for example, when reporting anomalies encountered for an iterating process that must not be interrupted. In which case multiple handling routines may be required. + + Sub Iteration + planets = Array("☿","♀","♁","♂","♃","♄","⛢","♆") + try: + On Error GoTo ReportAndProcessNext + For ndx = -3 To 11 Step 1 + MsgBox planets(ndx) + Next + On Error GoTo 0 ' Stop error catching + finally: + Exit Sub + ReportAndProcessNext: + Print "Error "& Err &" at line "& Erl &" - "& Error$ + Resume Next + End Sub ' Iteration + + Using Resume without parameters to re-execute the faulty instruction can fit certain situations. However that may cause a never ending loop. + +
\ No newline at end of file -- cgit v1.2.3