From abb9f587513acabada8d15c59508baefa7196540 Mon Sep 17 00:00:00 2001 From: LibreOfficiant Date: Sun, 5 Apr 2020 13:28:45 +0100 Subject: tdf#129366 Resume statement new help page its 3 available options are: - 0 - label - Next + associated examples in combination with On Error statement To be rebased past #91709 Change-Id: I0986816580835bf9b2b2657ecdbdc06118b1ff9d Reviewed-on: https://gerrit.libreoffice.org/c/help/+/91712 Tested-by: Olivier Hallot Reviewed-by: Olivier Hallot --- AllLangHelp_sbasic.mk | 1 + source/auxiliary/sbasic.tree | 1 + source/text/sbasic/shared/Resume.xhp | 77 ++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 source/text/sbasic/shared/Resume.xhp diff --git a/AllLangHelp_sbasic.mk b/AllLangHelp_sbasic.mk index 4b5999ba10..3860b45493 100644 --- a/AllLangHelp_sbasic.mk +++ b/AllLangHelp_sbasic.mk @@ -372,6 +372,7 @@ $(eval $(call gb_AllLangHelp_add_helpfiles,sbasic,\ helpcontent2/source/text/sbasic/shared/keys \ helpcontent2/source/text/sbasic/shared/main0211 \ helpcontent2/source/text/sbasic/shared/main0601 \ + helpcontent2/source/text/sbasic/shared/Resume \ helpcontent2/source/text/sbasic/shared/special_vba_func \ helpcontent2/source/text/sbasic/shared/vbasupport \ helpcontent2/source/text/sbasic/python/main0000 \ diff --git a/source/auxiliary/sbasic.tree b/source/auxiliary/sbasic.tree index d2924a7c77..c9fe8eaf16 100644 --- a/source/auxiliary/sbasic.tree +++ b/source/auxiliary/sbasic.tree @@ -241,6 +241,7 @@ PV Function [VBA] QBColor Function Rate Function [VBA] + Resume Statement RGB Function RSet Statement RTrim Function diff --git a/source/text/sbasic/shared/Resume.xhp b/source/text/sbasic/shared/Resume.xhp new file mode 100644 index 0000000000..7beae506a3 --- /dev/null +++ b/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 executes the instruction at the given label. + 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 propogation 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