Files
help/source/text/sbasic/shared/ErrVBA.xhp
Ilmari Lauhakangas 7e42394ecb tdf#152323 drop name attribute from <link> elements
Replacement done with

find . -name \*.xhp -print0 |xargs -0 -P 0 perl -CS -pi -e \
        's#(<link[^>]*?) +name *="[^"]*" *( [^>]+|) *>#$1$2>#g'

(note some inconsistencies with space between name and = and also having
empty value, and some more complicated expression to also clear up
double space before/after the attribute)

translation files will be prepped with:

find */helpcontent2 -name \*.po -print0 |xargs -0 -P 0 perl -CS -pi -e \
    $'s#(<link[^>]*?) +name=(?:\\\\"[^"]*\\\\"|\'[^\']*\') *( [^>]+|) *(/?>)#$1$2$3#g unless /^#/'

(note that not all languages use the " as quote character for the
attributes, but that also single quotes appera in the po file. Hence
the use of the shell $'string' syntax to be able to quote ' as \'
It also requires to quote the backslash, so that it needs to be escaped
once for the shell, then another time for perl. Also don't work on
obsolete strings (those are prefixed with #~ in the po files)
Also note that <link..></link> gets turned into <link ../> during
translation extraction (along with removal of the space between the
attribute name and the value), so the pattern needs to be slightly
different here)

Change-Id: I95e53a08e6b0095cd894109ea0de154cc4859d8f
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/143713
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2022-12-07 17:39:02 +00:00

133 lines
11 KiB
XML

<?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">Err Object [VBA]</link></variable></h1>
<paragraph role="paragraph" id="N0012">Use VBA <literal>Err</literal> object to raise or handle runtime errors.</paragraph>
</section>
<paragraph role="paragraph" id="N0012b"><literal>Err</literal> is a built-in VBA global object that allows:</paragraph>
<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">The 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">The <emph>Description</emph> property gives the nature of the error. <emph>Description</emph> details the various reasons that may be the cause of the error. Ideally, it provides the multiple course of actions to help solve the issue and prevent its reoccurrence. The Basic alias is the <link href="text/sbasic/shared/03050300.xhp">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">The error code associated with the error. <literal>Err</literal> object default property is <emph>Number</emph>. The %PRODUCTNAME Basic alias is the <link href="text/sbasic/shared/03050200.xhp">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">Erl</link>, number and source properties of current error. The %PRODUCTNAME Basic alias is the <link href="text/sbasic/shared/03050500.xhp">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. The %PRODUCTNAME Basic alias is the <link href="text/sbasic/shared/03050200.xhp">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>
<section id="RestrictedErrorCodes">
<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>
</section>
<paragraph role="paragraph" id="N0033"><emph>Source</emph>: The name of the routine raising the error. A name in the form of &quot;myLibrary.myModule.myProc&quot; 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, &quot;ThrowErrors&quot;, Error(91))</paragraph>
<paragraph role="bascode" id="N0041" xml-lang="en-US"> Err.Raise 2020, Description:=&quot;This is an intended user-defined error …&quot;</paragraph>
<paragraph role="bascode" id="N0042" localize="false"> Err.Raise(4096, &quot;Standard.Module1.ThrowErrors&quot;, 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 = &quot;Error &quot;&amp; Err &amp;&quot; at line &quot;&amp; Erl &amp;&quot; in &quot;&amp; 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">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, &quot;myLib.myModule.aRoutine&quot;, _</paragraph>
<paragraph role="bascode" id="N0078" xml-lang="en-US"> &quot;Any multi-line description for this user-defined exception&quot;)</paragraph>
<paragraph role="bascode" id="N0079" xml-lang="en-US"> &apos; 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 = &quot;Error &quot;&amp; Exc.Number &amp;&quot; at line &quot;&amp; Erl &amp;&quot; in &quot;&amp; 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">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/03050000.xhp#ErrHandlingh1"/>
<embed href="text/sbasic/shared/classmodule.xhp#classmodulestatement"/>
<embed href="text/sbasic/shared/03103350.xhp#vbasupportstatement"/>
<embed href="text/sbasic/shared/03/sf_exception.xhp#ExceptionService"/>
</section>
</body>
</helpdocument>