[Libreoffice-commits] help.git: AllLangHelp_sbasic.mk source/auxiliary source/text

LibreOfficiant (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 2 15:38:29 UTC 2020


 AllLangHelp_sbasic.mk                          |    1 
 source/auxiliary/sbasic.tree                   |    1 
 source/text/sbasic/shared/00000003.xhp         |    2 
 source/text/sbasic/shared/ErrVBA.xhp           |  127 +++++++++++++++++++++++++
 source/text/sbasic/shared/special_vba_func.xhp |    5 
 5 files changed, 133 insertions(+), 3 deletions(-)

New commits:
commit b6a60949a44df45c1ea13dcd5c7330d327860233
Author:     LibreOfficiant <LibreOfficiant at sfr.fr>
AuthorDate: Fri Mar 27 14:24:07 2020 +0100
Commit:     Olivier Hallot <olivier.hallot at libreoffice.org>
CommitDate: Thu Apr 2 17:38:09 2020 +0200

    VBA Err object
    
    - Handling exceptions or Throwing them w/ Basic
    
    A limited set of VBA ERR object properties & methods are exhibiting useful features.
    This page document that subset.
    
    Change-Id: I98726a6ffbce370b81f1a26daa35a8a1bf3dc57c
    Reviewed-on: https://gerrit.libreoffice.org/c/help/+/91177
    Tested-by: Jenkins
    Reviewed-by: Olivier Hallot <olivier.hallot at libreoffice.org>

diff --git a/AllLangHelp_sbasic.mk b/AllLangHelp_sbasic.mk
index 714338107..4b5999ba1 100644
--- a/AllLangHelp_sbasic.mk
+++ b/AllLangHelp_sbasic.mk
@@ -362,6 +362,7 @@ $(eval $(call gb_AllLangHelp_add_helpfiles,sbasic,\
     helpcontent2/source/text/sbasic/shared/compatible \
     helpcontent2/source/text/sbasic/shared/compatibilitymode \
     helpcontent2/source/text/sbasic/shared/enum \
+    helpcontent2/source/text/sbasic/shared/ErrVBA \
     helpcontent2/source/text/sbasic/shared/partition \
     helpcontent2/source/text/sbasic/shared/property \
     helpcontent2/source/text/sbasic/shared/replace \
diff --git a/source/auxiliary/sbasic.tree b/source/auxiliary/sbasic.tree
index bbc37c493..74996c65a 100644
--- a/source/auxiliary/sbasic.tree
+++ b/source/auxiliary/sbasic.tree
@@ -133,6 +133,7 @@
                     <topic id="sbasic/text/sbasic/shared/03060200.xhp">Eqv Operator</topic>
                     <topic id="sbasic/text/sbasic/shared/03050100.xhp">Erl Function</topic>
                     <topic id="sbasic/text/sbasic/shared/03050200.xhp">Err Function</topic>
+                    <topic id="sbasic/text/sbasic/shared/ErrVBA.xhp">Err Object [VBA]</topic>
                     <topic id="sbasic/text/sbasic/shared/03050300.xhp">Error Function</topic>
                     <topic id="sbasic/text/sbasic/shared/03050000.xhp">Error-Handling Functions</topic>
                     <topic id="sbasic/text/sbasic/shared/03090412.xhp">Exit Statement</topic>
diff --git a/source/text/sbasic/shared/00000003.xhp b/source/text/sbasic/shared/00000003.xhp
index b1eabffbc..848fb4cbd 100644
--- a/source/text/sbasic/shared/00000003.xhp
+++ b/source/text/sbasic/shared/00000003.xhp
@@ -187,7 +187,7 @@
 </section>
 
 <section id="vbasupport">
-    <warning id="par_id051920171018124524">This function or constant is enabled with the statement <link href="text/sbasic/shared/03103350.xhp" name="optionvbasupport"><literal>Option VBASupport 1</literal></link> placed before the executable program code in a module.</warning>
+    <warning id="par_id051920171018124524">This constant, function or object is enabled with the statement <link href="text/sbasic/shared/03103350.xhp" name="optionvbasupport"><literal>Option VBASupport 1</literal></link> placed before the executable program code in a module.</warning>
 </section>
 <section id="beforeexecutable">
     <warning id="par_id3145172">This statement must be added before the executable program code in a module.</warning>
diff --git a/source/text/sbasic/shared/ErrVBA.xhp b/source/text/sbasic/shared/ErrVBA.xhp
new file mode 100644
index 000000000..0e28e5107
--- /dev/null
+++ b/source/text/sbasic/shared/ErrVBA.xhp
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<helpdocument version="1.0">
+   <!--
+   * This file is part of the LibreOffice project.
+   *
+   * This Source Code Form is subject to the terms of the Mozilla Public
+   * License, v. 2.0. If a copy of the MPL was not distributed with this
+   * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+   *
+   -->
+   <meta>
+      <topic id="text/sbasic/shared/ErrVBA">
+         <title id="tit" xml-lang="en-US">Err VBA Object</title>
+         <filename>/text/sbasic/shared/ErrVBA.xhp</filename>
+      </topic>
+   </meta>
+   <body>
+      <section id="VBAErrObject">
+      <bookmark branch="index" id="N0010">
+         <bookmark_value>Err object</bookmark_value>
+         <bookmark_value>Error;raising</bookmark_value>
+         <bookmark_value>Error;handling</bookmark_value>
+      </bookmark>
+     <h1 id="N0011"><variable id="ErrVBAh1"><link href="text/sbasic/shared/ErrVBA.xhp" name="Err object [VBA]">Err Object [VBA]</link></variable></h1>
+     <paragraph role="paragraph" id="N0012">Use VBA <literal>Err</literal> object to raise or handle runtime errors. <literal>Err</literal> is a VBA built-in global object which permits:</paragraph>
+     </section>
+        <list type="unordered">
+         <listitem><paragraph role="paragraph" id="N0013">to raise predefined Basic errors</paragraph></listitem>
+         <listitem><paragraph role="paragraph" id="N0014">to throw user-defined exceptions</paragraph></listitem>
+         <listitem><paragraph role="paragraph" id="N0015">to name the routine originating the error</paragraph></listitem>
+         <listitem><paragraph role="paragraph" id="N0016">to describe the error and possible solutions</paragraph></listitem>
+      </list>
+      <embed href="text/sbasic/shared/00000003.xhp#vbasupport"/>
+      <paragraph role="paragraph" id="N0017">VBA <literal>Err</literal> object has the following properties and methods:</paragraph>
+      <h2 id="N0018">Properties</h2>
+      <bascode>
+         <paragraph role="bascode" id="N0019" localize="false">Err.Description As String</paragraph>
+      </bascode>
+      <paragraph role="paragraph" id="N0020"><emph>Description</emph> property gives the nature of the error. It details the various reasons that may cause the error. Ideally it provides the multiple course of actions that help solve the issue and prevent its reoccurrence. Its alias is Basic <link href="text/sbasic/shared/03050300.xhp" name ="Error function">Error</link> function for %PRODUCTNAME predefined errors.</paragraph>
+      <bascode>
+         <paragraph role="bascode" id="N0021" localize="false">Err.Number As Long</paragraph>
+      </bascode>
+     <paragraph role="paragraph" id="N0022">This the error code associated with the error. <literal>Err</literal> object default property is <emph>Number</emph>. Its alias is %PRODUCTNAME Basic <link href="text/sbasic/shared/03050200.xhp" name ="Err">Err</link> function.</paragraph>
+      <bascode>
+         <paragraph role="bascode" id="N0023" localize="false">Err.Source As String</paragraph>
+      </bascode>
+      <paragraph role="paragraph" id="N0024"><emph>Source</emph> indicates the name of the routine that produces the error. <emph>Source</emph> is an option for user-defined errors.</paragraph>
+      <h2 id="N0025">Methods</h2>
+      <bascode>
+         <paragraph role="bascode" id="N0026" localize="false">Err.Clear()</paragraph>
+      </bascode>
+      <paragraph role="paragraph" id="N0027">Resets description, <link href="text/sbasic/shared/03050100.xhp" name ="error line">Erl</link>, number and source properties of current error. Its alias is %PRODUCTNAME Basic <link href="text/sbasic/shared/03050500.xhp" name ="Resume statement">Resume</link> statement.</paragraph>
+      <bascode>
+         <paragraph role="bascode" id="N0028" localize="false">Err.Raise(Number As Long, Optional source As String, Optional description As String)</paragraph>
+      </bascode>
+      <paragraph role="paragraph" id="N0029">Throws user-defined errors or predefined errors. Its alias is %PRODUCTNAME Basic <link href="text/sbasic/shared/03050200.xhp" name ="Error statement">Error</link> statement.</paragraph>
+      <h3 id="N0030">Parameters</h3>
+      <paragraph role="paragraph" id="N0031"><emph>Number</emph> A user-defined or predefined error code to be raised.</paragraph>
+      <note id="N0032">Error code range 0-2000 is reserved for %PRODUCTNAME Basic. User-defined errors may start from higher values in order to prevent collision with %PRODUCTNAME Basic future developments.</note>
+      <paragraph role="paragraph" id="N0033"><emph>Source</emph> The name of the routine raising the error. A name in the form of "myLibrary.myModule.myProc" is recommended.</paragraph>
+      <paragraph role="paragraph" id="N0034"><emph>Description</emph> A description of the problem leading to stop the running process, accompanied with the various reasons that may cause it. A detailed list of the possible course of actions that may help solve the problem is recommended.</paragraph>
+      <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+      <bascode>
+         <paragraph role="bascode" id="N0036" localize="false">Option VBASupport 1</paragraph>
+         <paragraph role="bascode" id="N0037" localize="false"> </paragraph>
+         <paragraph role="bascode" id="N0038" localize="false">Sub ThrowErrors</paragraph>
+         <paragraph role="bascode" id="N0039" localize="false">    Dim aDesc As String : aDesc = Space(80)</paragraph>
+         <paragraph role="bascode" id="N003A" localize="false">    On Local Error GoTo AlertAndExecNext</paragraph>
+         <paragraph role="bascode" id="N0040" localize="false">    Err.Raise(91, "ThrowErrors", Error(91))</paragraph>
+         <paragraph role="bascode" id="N0041" xml-lang="en-US">    Err.Raise 2020, Description:="This is an intented user-defined error …"</paragraph>
+         <paragraph role="bascode" id="N0042" localize="false">    Err.Raise(4096, "Standard.Module1.ThrowErrors", aDesc)</paragraph>
+         <paragraph role="bascode" id="N0043" localize="false">    Exit Sub</paragraph>
+         <paragraph role="bascode" id="N0044" localize="false">AlertAndExecNext:</paragraph>
+         <paragraph role="bascode" id="N0045" xml-lang="en-US">    errTitle = "Error "& Err &" at line "& Erl &" in "& Err.Source</paragraph>
+         <paragraph role="bascode" id="N0046" localize="false">    MsgBox Err.Description, MB_ICONEXCLAMATION, errTitle</paragraph>
+         <paragraph role="bascode" id="N0047" localize="false">    Resume Next</paragraph>
+         <paragraph role="bascode" id="N0048" localize="false">End Sub</paragraph>
+      </bascode>
+      <h2 id="N0050">Exception ClassModule</h2>
+      <tip id="N0049">A short <link href="text/sbasic/shared/classmodule.xhp" name="ClassModule option">ClassModule</link>, that wraps VBA <literal>Err</literal> object, can distribute <literal>Err</literal> properties and methods for standard %PRODUCTNAME Basic modules.</tip>
+      <bascode>
+         <paragraph role="bascode" id="N0051" localize="false">Option ClassModule</paragraph>
+         <paragraph role="bascode" id="N0052" localize="false">Option VBASupport 1</paragraph>
+         <paragraph role="bascode" id="N0053" localize="false"> </paragraph>
+         <paragraph role="bascode" id="N0054" localize="false">Public Property Get Description As String</paragraph>
+         <paragraph role="bascode" id="N0055" localize="false">    Description = Err.Description</paragraph>
+         <paragraph role="bascode" id="N0056" localize="false">End Property</paragraph>
+         <paragraph role="bascode" id="N0057" localize="false">Public Property Get Number As Long</paragraph>
+         <paragraph role="bascode" id="N0058" localize="false">    Number = Err.Number</paragraph>
+         <paragraph role="bascode" id="N0059" localize="false">End Property</paragraph>
+         <paragraph role="bascode" id="N0060" localize="false">Public Property Get Source As String</paragraph>
+         <paragraph role="bascode" id="N0061" localize="false">    Source = Err.Source</paragraph>
+         <paragraph role="bascode" id="N0062" localize="false">End Property</paragraph>
+         <paragraph role="bascode" id="N0063" localize="false">Public Sub Clear</paragraph>
+         <paragraph role="bascode" id="N0064" localize="false">    Err.Clear</paragraph>
+         <paragraph role="bascode" id="N0065" localize="false">End Sub</paragraph>
+         <paragraph role="bascode" id="N0066" localize="false">Public Sub Raise( number As Long, Optional Source As String, Optional Description As String)</paragraph>
+         <paragraph role="bascode" id="N0067" localize="false">    Err.Raise number, Source, Description</paragraph>
+         <paragraph role="bascode" id="N0068" localize="false">End Sub</paragraph>
+      </bascode>
+      <h2 id="N0069">Example</h2>
+      <bascode>
+         <paragraph role="bascode" id="N0070" localize="false">Function Exc As Object</paragraph>
+         <paragraph role="bascode" id="N0071" localize="false">    Exc = New Exception</paragraph>
+         <paragraph role="bascode" id="N0072" localize="false">End Function</paragraph>
+         <paragraph role="bascode" id="N0073" localize="false"> </paragraph>
+         <paragraph role="bascode" id="N0074" localize="false">Sub aRoutine</paragraph>
+         <paragraph role="bascode" id="N0075" localize="false">try:</paragraph>
+         <paragraph role="bascode" id="N0076" localize="false">    On Local Error GoTo catch:</paragraph>
+         <paragraph role="bascode" id="N0077" localize="false">    Exc.Raise(4096, "myLib.myModule.aRoutine", _</paragraph>
+         <paragraph role="bascode" id="N0078" xml-lang="en-US">        "Any multi-line description for this user-defined exception")</paragraph>
+         <paragraph role="bascode" id="N0079" xml-lang="en-US">    ' your code goes here …</paragraph>
+         <paragraph role="bascode" id="N0080" localize="false">finally:</paragraph>
+         <paragraph role="bascode" id="N0081" localize="false">    Exit Sub</paragraph>
+         <paragraph role="bascode" id="N0082" localize="false">catch:</paragraph>
+         <paragraph role="bascode" id="N0083" xml-lang="en-US">    errTitle = "Error "& Exc.Number &" at line "& Erl &" in "& Exc.Source</paragraph>
+         <paragraph role="bascode" id="N0084" localize="false">    MsgBox Exc.Description, MB_ICONSTOP, errTitle</paragraph>
+         <paragraph role="bascode" id="N0085" localize="false">    Resume finally</paragraph>
+         <paragraph role="bascode" id="N0086" localize="false">End Sub</paragraph>
+      </bascode>
+      <note id="N0088">The <link href="text/sbasic/shared/03050300.xhp" name="Error statement">Error</link> statement or an Exception-like class module can be used interchangeably, while the latter adds extra features.</note>
+      <section id="relatedtopics">
+         <embed href="text/sbasic/shared/classmodule.xhp#classmodulestatement"/>
+         <embed href="text/sbasic/shared/03103350.xhp#vbasupportstatement"/>
+      </section>
+  </body>
+</helpdocument>
\ No newline at end of file
diff --git a/source/text/sbasic/shared/special_vba_func.xhp b/source/text/sbasic/shared/special_vba_func.xhp
index 14ce307dd..32d98942e 100644
--- a/source/text/sbasic/shared/special_vba_func.xhp
+++ b/source/text/sbasic/shared/special_vba_func.xhp
@@ -116,10 +116,11 @@
 <section id="VBAObject">
 
 <bookmark xml-lang="en-US" branch="index" id="bm_id051920170359045662">
-  <bookmark_value>VBA Functions;Object Functions</bookmark_value>
+  <bookmark_value>VBA Functions;Object Properties and Methods</bookmark_value>
 </bookmark>
 
-<paragraph id="hd_id051920170347039686" role="heading" level="2" xml-lang="en-US">Object Functions</paragraph>
+<paragraph id="hd_id051920170347039686" role="heading" level="2" xml-lang="en-US">Object Properties and Methods</paragraph>
+<embed href="text/sbasic/shared/ErrVBA.xhp#VBAErrObject"/>
 
 </section>
 </body>


More information about the Libreoffice-commits mailing list