tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / wizards / source / scriptforge / SF_Exception.xba
blobad0566ddfe9f15852d9fcfdb23265664f4cb8887
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_Exception" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
4 REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
5 REM === Full documentation is available on https://help.libreoffice.org/ ===
6 REM =======================================================================================================================
8 Option Compatible
9 Option Explicit
11 &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
12 &apos;&apos;&apos; Exception (aka SF_Exception)
13 &apos;&apos;&apos; =========
14 &apos;&apos;&apos; Generic singleton class for Basic code debugging and error handling
15 &apos;&apos;&apos;
16 &apos;&apos;&apos; Errors may be generated by
17 &apos;&apos;&apos; the Basic run-time error detection
18 &apos;&apos;&apos; in the ScriptForge code =&gt; RaiseAbort()
19 &apos;&apos;&apos; in a user code =&gt; Raise()
20 &apos;&apos;&apos; an error detection implemented
21 &apos;&apos;&apos; in the ScriptForge code =&gt; RaiseFatal()
22 &apos;&apos;&apos; in a user code =&gt; Raise() or RaiseWarning()
23 &apos;&apos;&apos;
24 &apos;&apos;&apos; When a run-time error occurs, the properties of the Exception object are filled
25 &apos;&apos;&apos; with information that uniquely identifies the error and information that can be used to handle it
26 &apos;&apos;&apos; The SF_Exception object is in this context similar to the VBA Err object
27 &apos;&apos;&apos; See https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/err-object
28 &apos;&apos;&apos; The Number property identifies the error: it can be a numeric value or a string
29 &apos;&apos;&apos; Numeric values up to 2000 are considered Basic run-time errors
30 &apos;&apos;&apos;
31 &apos;&apos;&apos; The &quot;console&quot; logs events, actual variable values, errors, ... It is an easy mean
32 &apos;&apos;&apos; to debug Basic programs especially when the IDE is not usable, f.i. in Calc user defined functions
33 &apos;&apos;&apos; or during control events processing
34 &apos;&apos;&apos; =&gt; DebugPrint()
35 &apos;&apos;&apos;
36 &apos;&apos;&apos; The usual behaviour of the application when an error occurs is:
37 &apos;&apos;&apos; 1. Log the error in the console
38 &apos;&apos;&apos; 2, Inform the user about the error with either a standard or a customized message
39 &apos;&apos;&apos; 3. Optionally, stop the execution of the current macro
40 &apos;&apos;&apos;
41 &apos;&apos;&apos; Detailed user documentation:
42 &apos;&apos;&apos; https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_exception.html?DbPAR=BASIC
43 &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
45 REM ================================================================== EXCEPTIONS
47 &apos; SF_Utils
48 Const MISSINGARGERROR = &quot;MISSINGARGERROR&quot;
49 Const ARGUMENTERROR = &quot;ARGUMENTERROR&quot;
50 Const ARRAYERROR = &quot;ARRAYERROR&quot;
51 Const FILEERROR = &quot;FILEERROR&quot;
53 &apos; SF_Array
54 Const ARRAYSEQUENCEERROR = &quot;ARRAYSEQUENCEERROR&quot;
55 Const ARRAYINSERTERROR = &quot;ARRAYINSERTERROR&quot;
56 Const ARRAYINDEX1ERROR = &quot;ARRAYINDEX1ERROR&quot;
57 Const ARRAYINDEX2ERROR = &quot;ARRAYINDEX2ERROR&quot;
58 Const CSVPARSINGERROR = &quot;CSVPARSINGERROR&quot;
59 Const CSVOVERFLOWWARNING = &quot;CSVOVERFLOWWARNING&quot;
61 &apos; SF_Dictionary
62 Const DUPLICATEKEYERROR = &quot;DUPLICATEKEYERROR&quot;
63 Const UNKNOWNKEYERROR = &quot;UNKNOWNKEYERROR&quot;
64 Const INVALIDKEYERROR = &quot;INVALIDKEYERROR&quot;
66 &apos; SF_FileSystem
67 Const UNKNOWNFILEERROR = &quot;UNKNOWNFILEERROR&quot;
68 Const UNKNOWNFOLDERERROR = &quot;UNKNOWNFOLDERERROR&quot;
69 Const NOTAFILEERROR = &quot;NOTAFILEERROR&quot;
70 Const NOTAFOLDERERROR = &quot;NOTAFOLDERERROR&quot;
71 Const OVERWRITEERROR = &quot;OVERWRITEERROR&quot;
72 Const READONLYERROR = &quot;READONLYERROR&quot;
73 Const NOFILEMATCHERROR = &quot;NOFILEMATCHFOUND&quot;
74 Const FOLDERCREATIONERROR = &quot;FOLDERCREATIONERROR&quot;
75 Const FILESYSTEMERROR = &quot;FILESYSTEMERROR&quot;
77 &apos; SF_Services
78 Const UNKNOWNSERVICEERROR = &quot;UNKNOWNSERVICEERROR&quot;
79 Const SERVICESNOTLOADEDERROR = &quot;SERVICESNOTLOADEDERROR&quot;
81 &apos; SF_Session
82 Const CALCFUNCERROR = &quot;CALCFUNCERROR&quot;
83 Const NOSCRIPTERROR = &quot;NOSCRIPTERROR&quot;
84 Const SCRIPTEXECERROR = &quot;SCRIPTEXECERROR&quot;
85 Const WRONGEMAILERROR = &quot;WRONGEMAILERROR&quot;
86 Const SENDMAILERROR = &quot;SENDMAILERROR&quot;
88 &apos; SF_TextStream
89 Const FILENOTOPENERROR = &quot;FILENOTOPENERROR&quot;
90 Const FILEOPENMODEERROR = &quot;FILEOPENMODEERROR&quot;
91 Const ENDOFFILEERROR = &quot;ENDOFFILEERROR&quot;
93 &apos; SF_UI
94 Const DOCUMENTERROR = &quot;DOCUMENTERROR&quot;
95 Const DOCUMENTCREATIONERROR = &quot;DOCUMENTCREATIONERROR&quot;
96 Const DOCUMENTOPENERROR = &quot;DOCUMENTOPENERROR&quot;
97 Const BASEDOCUMENTOPENERROR = &quot;BASEDOCUMENTOPENERROR&quot;
99 &apos; SF_Document
100 Const DOCUMENTDEADERROR = &quot;DOCUMENTDEADERROR&quot;
101 Const DOCUMENTSAVEERROR = &quot;DOCUMENTSAVEERROR&quot;
102 Const DOCUMENTSAVEASERROR = &quot;DOCUMENTSAVEASERROR&quot;
103 Const DOCUMENTREADONLYERROR = &quot;DOCUMENTREADONLYERROR&quot;
104 Const DBCONNECTERROR = &quot;DBCONNECTERROR&quot;
106 &apos; SF_Calc
107 Const CALCADDRESSERROR = &quot;CALCADDRESSERROR&quot;
108 Const DUPLICATESHEETERROR = &quot;DUPLICATESHEETERROR&quot;
109 Const OFFSETADDRESSERROR = &quot;OFFSETADDRESSERROR&quot;
110 Const DUPLICATECHARTERROR = &quot;DUPLICATECHARTERROR&quot;
111 Const RANGEEXPORTERROR = &quot;RANGEEXPORTERROR&quot;
113 &apos; SF_Chart
114 Const CHARTEXPORTERROR = &quot;CHARTEXPORTERROR&quot;
116 &apos; SF_Form
117 Const FORMDEADERROR = &quot;FORMDEADERROR&quot;
118 Const CALCFORMNOTFOUNDERROR = &quot;CALCFORMNOTFOUNDERROR&quot;
119 Const WRITERFORMNOTFOUNDERROR = &quot;WRITERFORMNOTFOUNDERROR&quot;
120 Const BASEFORMNOTFOUNDERROR = &quot;BASEFORMNOTFOUNDERROR&quot;
121 Const SUBFORMNOTFOUNDERROR = &quot;SUBFORMNOTFOUNDERROR&quot;
122 Const FORMCONTROLTYPEERROR = &quot;FORMCONTROLTYPEERROR&quot;
124 &apos; SF_Writer
125 Const WRITERRANGEERROR = &quot;WRITERRANGEERROR&quot;
127 &apos; SF_Dialog
128 Const DIALOGNOTFOUNDERROR = &quot;DIALOGNOTFOUNDERROR&quot;
129 Const DIALOGDEADERROR = &quot;DIALOGDEADERROR&quot;
130 Const CONTROLTYPEERROR = &quot;CONTROLTYPEERROR&quot;
131 Const TEXTFIELDERROR = &quot;TEXTFIELDERROR&quot;
132 Const PAGEMANAGERERROR = &quot;PAGEMANAGERERROR&quot;
133 Const DUPLICATECONTROLERROR = &quot;DUPLICATECONTROLERROR&quot;
135 &apos; SF_Database
136 Const DBREADONLYERROR = &quot;DBREADONLYERROR&quot;
137 Const SQLSYNTAXERROR = &quot;SQLSYNTAXERROR&quot;
138 Const SQLSYNTAX2ERROR = &quot;SQLSYNTAX2ERROR&quot;
139 Const NOCURRENTRECORDERROR = &quot;NOCURRENTRECORDERROR&quot;
140 Const RECORDUPDATEERROR = &quot;RECORDUPDATEERROR&quot;
141 Const FIELDEXPORTERROR = &quot;FIELDEXPORTERROR&quot;
143 &apos; Python
144 Const PYTHONSHELLERROR = &quot;PYTHONSHELLERROR&quot;
146 &apos; SF_UnitTest
147 Const UNITTESTLIBRARYERROR = &quot;UNITTESTLIBRARYERROR&quot;
148 Const UNITTESTMETHODERROR = &quot;UNITTESTMETHODERROR&quot;
150 REM ============================================================= PRIVATE MEMBERS
152 &apos; User defined errors
153 Private _Number As Variant &apos; Error number/code (Integer or String)
154 Private _Source As Variant &apos; Where the error occurred: a module, a Sub/Function, ...
155 Private _Description As String &apos; The error message
157 &apos; System run-time errors
158 Private _SysNumber As Long &apos; Alias of Err
159 Private _SysSource As Long &apos; Alias of Erl
160 Private _SysDescription As String &apos; Alias of Error$
162 REM ============================================================ MODULE CONSTANTS
164 Const RUNTIMEERRORS = 2000 &apos; Upper limit of Basic run-time errors
165 Const CONSOLENAME = &quot;ConsoleLines&quot; &apos; Name of control in the console dialog
167 REM ===================================================== CONSTRUCTOR/DESTRUCTOR
169 REM -----------------------------------------------------------------------------
170 Public Function Dispose() As Variant
171 Set Dispose = Nothing
172 End Function &apos; ScriptForge.SF_Exception Explicit destructor
174 REM ================================================================== PROPERTIES
176 REM -----------------------------------------------------------------------------
177 Property Get Description() As Variant
178 &apos;&apos;&apos; Returns the description of the last error that has occurred
179 &apos;&apos;&apos; Example:
180 &apos;&apos;&apos; myException.Description
181 Description = _PropertyGet(&quot;Description&quot;)
182 End Property &apos; ScriptForge.SF_Exception.Description (get)
184 REM -----------------------------------------------------------------------------
185 Property Let Description(ByVal pvDescription As Variant)
186 &apos;&apos;&apos; Set the description of the last error that has occurred
187 &apos;&apos;&apos; Example:
188 &apos;&apos;&apos; myException.Description = &quot;Not smart to divide by zero&quot;
189 _PropertySet &quot;Description&quot;, pvDescription
190 End Property &apos; ScriptForge.SF_Exception.Description (let)
192 REM -----------------------------------------------------------------------------
193 Property Get Number() As Variant
194 &apos;&apos;&apos; Returns the code of the last error that has occurred
195 &apos;&apos;&apos; Example:
196 &apos;&apos;&apos; myException.Number
197 Number = _PropertyGet(&quot;Number&quot;)
198 End Property &apos; ScriptForge.SF_Exception.Number (get)
200 REM -----------------------------------------------------------------------------
201 Property Let Number(ByVal pvNumber As Variant)
202 &apos;&apos;&apos; Set the code of the last error that has occurred
203 &apos;&apos;&apos; Example:
204 &apos;&apos;&apos; myException.Number = 11 &apos; Division by 0
205 _PropertySet &quot;Number&quot;, pvNumber
206 End Property &apos; ScriptForge.SF_Exception.Number (let)
208 REM -----------------------------------------------------------------------------
209 Property Get Source() As Variant
210 &apos;&apos;&apos; Returns the location of the last error that has occurred
211 &apos;&apos;&apos; Example:
212 &apos;&apos;&apos; myException.Source
213 Source = _PropertyGet(&quot;Source&quot;)
214 End Property &apos; ScriptForge.SF_Exception.Source (get)
216 REM -----------------------------------------------------------------------------
217 Property Let Source(ByVal pvSource As Variant)
218 &apos;&apos;&apos; Set the location of the last error that has occurred
219 &apos;&apos;&apos; Example:
220 &apos;&apos;&apos; myException.Source = 123 &apos; Line # 123. Source may also be a string
221 _PropertySet &quot;Source&quot;, pvSource
222 End Property &apos; ScriptForge.SF_Exception.Source (let)
224 REM -----------------------------------------------------------------------------
225 Property Get ObjectType As String
226 &apos;&apos;&apos; Only to enable object representation
227 ObjectType = &quot;SF_Exception&quot;
228 End Property &apos; ScriptForge.SF_String.ObjectType
230 REM -----------------------------------------------------------------------------
231 Property Get ServiceName As String
232 &apos;&apos;&apos; Internal use
233 ServiceName = &quot;ScriptForge.Exception&quot;
234 End Property &apos; ScriptForge.SF_Exception.ServiceName
236 REM ===================================================================== METHODS
238 REM -----------------------------------------------------------------------------
239 Public Sub Clear()
240 &apos;&apos;&apos; Reset the current error status and clear the SF_Exception object
241 &apos;&apos;&apos; Args:
242 &apos;&apos;&apos; Examples:
243 &apos;&apos;&apos; On Local Error GoTo Catch
244 &apos;&apos;&apos; &apos; ...
245 &apos;&apos;&apos; Catch:
246 &apos;&apos;&apos; SF_Exception.Clear() &apos; Deny the error
248 Const cstThisSub = &quot;Exception.Clear&quot;
249 Const cstSubArgs = &quot;&quot;
251 Check:
253 Try:
254 With SF_Exception
255 ._Number = Empty
256 ._Source = Empty
257 ._Description = &quot;&quot;
258 ._SysNumber = 0
259 ._SysSource = 0
260 ._SysDescription = &quot;&quot;
261 End With
263 Finally:
264 On Error GoTo 0
265 Exit Sub
266 Catch:
267 GoTo Finally
268 End Sub &apos; ScriptForge.SF_Exception.Clear
270 REM -----------------------------------------------------------------------------
271 Public Sub Console(Optional ByVal Modal As Variant, _
272 Optional ByRef _Context As Variant _
274 &apos;&apos;&apos; Display the console messages in a modal or non-modal dialog
275 &apos;&apos;&apos; If the dialog is already active, when non-modal, it is brought to front
276 &apos;&apos;&apos; Args:
277 &apos;&apos;&apos; Modal: Boolean. Default = True
278 &apos;&apos;&apos; _Context: From Python, the XComponentXontext (FOR INTERNAL USE ONLY)
279 &apos;&apos;&apos; Example:
280 &apos;&apos;&apos; SF_Exception.Console()
282 Dim bConsoleActive As Boolean &apos; When True, dialog is active
283 Dim oModalBtn As Object &apos; Modal close button
284 Dim oNonModalBtn As Object &apos; Non modal close button
285 Const cstThisSub = &quot;Exception.Console&quot;
286 Const cstSubArgs = &quot;[Modal=True]&quot;
288 &apos; Save Err, Erl, .. values before any On Error ... statement
289 SF_Exception._CaptureSystemError()
290 If SF_Utils._ErrorHandling() Then On Local Error GoTo Finally &apos; Never interrupt processing
292 Check:
293 If IsMissing(Modal) Or IsEmpty(Modal) Then Modal = True
294 If IsMissing(_Context) Or IsEmpty(_Context) Then _Context = Nothing
295 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
296 If Not SF_Utils._Validate(Modal, &quot;Modal&quot;, V_BOOLEAN) Then GoTo Finally
297 End If
299 Try:
300 With _SF_
301 bConsoleActive = False
302 If Not IsNull(.ConsoleDialog) Then bConsoleActive = .ConsoleDialog._IsStillAlive(False) &apos; False to not raise an error
303 If bConsoleActive And Modal = False Then
304 &apos; Bring to front
305 .ConsoleDialog.Activate()
306 Else
307 &apos; Initialize dialog and fill with actual data
308 &apos; The dual modes (modal and non-modal) require to have 2 close buttons o/w only 1 is visible
309 &apos; - a usual OK button
310 &apos; - a Default button triggering the Close action
311 Set .ConsoleDialog = CreateScriptService(&quot;SFDialogs.Dialog&quot;, &quot;GlobalScope&quot;, &quot;ScriptForge&quot;, &quot;dlgConsole&quot;, _Context)
312 &apos; Setup labels and visibility
313 Set oModalBtn = .ConsoleDialog.Controls(&quot;CloseModalButton&quot;)
314 Set oNonModalBtn = .ConsoleDialog.Controls(&quot;CloseNonModalButton&quot;)
315 oModalBtn.Visible = Modal
316 oNonModalBtn.Visible = CBool(Not Modal)
317 &apos; Load console lines
318 _ConsoleRefresh()
319 .ConsoleDialog.Execute(Modal)
320 &apos; Terminate the modal dialog
321 If Modal Then
322 Set .ConsoleControl = .ConsoleControl.Dispose()
323 Set .ConsoleDialog = .ConsoleDialog.Dispose()
324 End If
325 End If
326 End With
328 Finally:
329 SF_Utils._ExitFunction(cstThisSub)
330 Exit Sub
331 End Sub &apos; ScriptForge.SF_Exception.Console
333 REM -----------------------------------------------------------------------------
334 Public Sub ConsoleClear(Optional ByVal Keep)
335 &apos;&apos;&apos; Clear the console keeping an optional number of recent messages
336 &apos;&apos;&apos; Args:
337 &apos;&apos;&apos; Keep: the number of messages to keep
338 &apos;&apos;&apos; If Keep is bigger than the number of messages stored in the console,
339 &apos;&apos;&apos; the console is not cleared
340 &apos;&apos;&apos; Example:
341 &apos;&apos;&apos; SF_Exception.ConsoleClear(5)
343 Dim lConsole As Long &apos; UBound of ConsoleLines
344 Const cstThisSub = &quot;Exception.ConsoleClear&quot;
345 Const cstSubArgs = &quot;[Keep=0]&quot;
347 &apos; Save Err, Erl, .. values before any On Error ... statement
348 SF_Exception._CaptureSystemError()
349 If SF_Utils._ErrorHandling() Then On Local Error GoTo Finally &apos; Never interrupt processing
351 Check:
352 If IsMissing(Keep) Or IsEmpty(Keep) Then Keep = 0
353 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
354 If Not SF_Utils._Validate(Keep, &quot;Keep&quot;, V_NUMERIC) Then GoTo Finally
355 End If
357 Try:
358 With _SF_
359 If Keep &lt;= 0 Then
360 .ConsoleLines = Array()
361 Else
362 lConsole = UBound(.ConsoleLines)
363 If Keep &lt; lConsole + 1 Then .ConsoleLines = SF_Array.Slice(.ConsoleLines, lConsole - Keep + 1)
364 End If
365 End With
367 &apos; If active, the console dialog needs to be refreshed
368 _ConsoleRefresh()
370 Finally:
371 SF_Utils._ExitFunction(cstThisSub)
372 Exit Sub
373 End Sub &apos; ScriptForge.SF_Exception.ConsoleClear
375 REM -----------------------------------------------------------------------------
376 Public Function ConsoleToFile(Optional ByVal FileName As Variant) As Boolean
377 &apos;&apos;&apos; Export the content of the console to a text file
378 &apos;&apos;&apos; If the file exists and the console is not empty, it is overwritten without warning
379 &apos;&apos;&apos; Args:
380 &apos;&apos;&apos; FileName: the complete file name to export to. If it exists, is overwritten without warning
381 &apos;&apos;&apos; Returns:
382 &apos;&apos;&apos; True if the file could be created
383 &apos;&apos;&apos; Examples:
384 &apos;&apos;&apos; SF_Exception.ConsoleToFile(&quot;myFile.txt&quot;)
386 Dim bExport As Boolean &apos; Return value
387 Dim oFile As Object &apos; Output file handler
388 Dim sLine As String &apos; A single line
389 Const cstThisSub = &quot;Exception.ConsoleToFile&quot;
390 Const cstSubArgs = &quot;FileName&quot;
392 &apos; Save Err, Erl, .. values before any On Error ... statement
393 SF_Exception._CaptureSystemError()
394 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
395 bExport = False
397 Check:
398 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
399 If Not SF_Utils._ValidateFile(FileName, &quot;FileName&quot;) Then GoTo Finally
400 End If
402 Try:
404 If UBound(_SF_.ConsoleLines) &gt; -1 Then
405 Set oFile = SF_FileSystem.CreateTextFile(FileName, Overwrite := True)
406 If Not IsNull(oFile) Then
407 With oFile
408 For Each sLine In _SF_.ConsoleLines
409 .WriteLine(sLine)
410 Next sLine
411 .CloseFile()
412 End With
413 End If
414 bExport = True
415 End If
417 Finally:
418 If Not IsNull(oFile) Then Set oFile = oFile.Dispose()
419 ConsoleToFile = bExport
420 SF_Utils._ExitFunction(cstThisSub)
421 Exit Function
422 Catch:
423 GoTo Finally
424 End Function &apos; ScriptForge.SF_Exception.ConsoleToFile
426 REM -----------------------------------------------------------------------------
427 Public Sub DebugDisplay(ParamArray pvArgs() As Variant)
428 &apos;&apos;&apos; Display the list of arguments in a readable form in a message box
429 &apos;&apos;&apos; Arguments are separated by a LINEFEED character
430 &apos;&apos;&apos; The maximum length of each individual argument = 1024 characters
431 &apos;&apos;&apos; Args:
432 &apos;&apos;&apos; Any number of arguments of any type
433 &apos;&apos;&apos; Examples:
434 &apos;&apos;&apos; SF_Exception.DebugDisplay(a, Array(1, 2, 3), , &quot;line1&quot; &amp; Chr(10) &amp; &quot;Line2&quot;, DateSerial(2020, 04, 09))
436 Dim sOutputMsg As String &apos; Line to display
437 Dim sOutputCon As String &apos; Line to write in console
438 Dim sArgMsg As String &apos; Single argument
439 Dim sArgCon As String &apos; Single argument
440 Dim i As Integer
441 Const cstTab = 4
442 Const cstMaxLength = 1024
443 Const cstThisSub = &quot;Exception.DebugDisplay&quot;
444 Const cstSubArgs = &quot;Arg0, [Arg1, ...]&quot;
446 &apos; Save Err, Erl, .. values before any On Error ... statement
447 SF_Exception._CaptureSystemError()
448 If SF_Utils._ErrorHandling() Then On Local Error Goto Finally &apos; Never interrupt processing
449 SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
450 Try:
451 &apos; Build new console line
452 sOutputMsg = &quot;&quot; : sOutputCon = &quot;&quot;
453 For i = 0 To UBound(pvArgs)
454 If IsError(pvArgs(i)) Then pvArgs(i) = &quot;&quot;
455 sArgMsg = Iif(i = 0, &quot;&quot;, SF_String.sfNEWLINE) &amp; SF_Utils._Repr(pvArgs(i), cstMaxLength) &apos;Do not use SF_String.Represent()
456 sArgCon = Iif(i = 0, &quot;&quot;, SF_String.sfTAB) &amp; SF_Utils._Repr(pvArgs(i), cstMaxLength)
457 sOutputMsg = sOutputMsg &amp; sArgMsg
458 sOutputCon = sOutputCon &amp; sArgCon
459 Next i
461 &apos; Add to actual console
462 _SF_._AddToConsole(SF_String.ExpandTabs(sOutputCon, cstTab))
463 &apos; Display the message
464 MsgBox(sOutputMsg, MB_OK + MB_ICONINFORMATION, &quot;DebugDisplay&quot;)
466 Finally:
467 SF_Utils._ExitFunction(cstThisSub)
468 Exit Sub
469 End Sub &apos; ScriptForge.SF_Exception.DebugDisplay
471 REM -----------------------------------------------------------------------------
472 Public Sub DebugPrint(ParamArray pvArgs() As Variant)
473 &apos;&apos;&apos; Print the list of arguments in a readable form in the console
474 &apos;&apos;&apos; Arguments are separated by a TAB character (simulated by spaces)
475 &apos;&apos;&apos; The maximum length of each individual argument = 1024 characters
476 &apos;&apos;&apos; Args:
477 &apos;&apos;&apos; Any number of arguments of any type
478 &apos;&apos;&apos; Examples:
479 &apos;&apos;&apos; SF_Exception.DebugPrint(a, Array(1, 2, 3), , &quot;line1&quot; &amp; Chr(10) &amp; &quot;Line2&quot;, DateSerial(2020, 04, 09))
481 Dim sOutput As String &apos; Line to write in console
482 Dim sArg As String &apos; Single argument
483 Dim i As Integer
484 Const cstTab = 4
485 Const cstMaxLength = 1024
486 Const cstThisSub = &quot;Exception.DebugPrint&quot;
487 Const cstSubArgs = &quot;Arg0, [Arg1, ...]&quot;
489 &apos; Save Err, Erl, .. values before any On Error ... statement
490 SF_Exception._CaptureSystemError()
491 If SF_Utils._ErrorHandling() Then On Local Error Goto Finally &apos; Never interrupt processing
492 SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
493 Try:
494 &apos; Build new console line
495 sOutput = &quot;&quot;
496 For i = 0 To UBound(pvArgs)
497 If IsError(pvArgs(i)) Then pvArgs(i) = &quot;&quot;
498 sArg = Iif(i = 0, &quot;&quot;, SF_String.sfTAB) &amp; SF_Utils._Repr(pvArgs(i), cstMaxLength) &apos;Do not use SF_String.Represent()
499 sOutput = sOutput &amp; sArg
500 Next i
502 &apos; Add to actual console
503 _SF_._AddToConsole(SF_String.ExpandTabs(sOutput, cstTab))
505 Finally:
506 SF_Utils._ExitFunction(cstThisSub)
507 Exit Sub
508 End Sub &apos; ScriptForge.SF_Exception.DebugPrint
510 REM -----------------------------------------------------------------------------
511 Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
512 &apos;&apos;&apos; Return the actual value of the given property
513 &apos;&apos;&apos; Args:
514 &apos;&apos;&apos; PropertyName: the name of the property as a string
515 &apos;&apos;&apos; Returns:
516 &apos;&apos;&apos; The actual value of the property
517 &apos;&apos;&apos; If the property does not exist, returns Null
518 &apos;&apos;&apos; Exceptions
519 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
520 &apos;&apos;&apos; Examples:
521 &apos;&apos;&apos; myException.GetProperty(&quot;MyProperty&quot;)
523 Const cstThisSub = &quot;Exception.GetProperty&quot;
524 Const cstSubArgs = &quot;&quot;
526 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
527 GetProperty = Null
529 Check:
530 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
531 If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
532 End If
534 Try:
535 GetProperty = _PropertyGet(PropertyName)
537 Finally:
538 SF_Utils._ExitFunction(cstThisSub)
539 Exit Function
540 Catch:
541 GoTo Finally
542 End Function &apos; ScriptForge.SF_Exception.GetProperty
544 REM -----------------------------------------------------------------------------
545 Public Function Methods() As Variant
546 &apos;&apos;&apos; Return the list of public methods of the Exception service as an array
548 Methods = Array( _
549 &quot;Clear&quot; _
550 , &quot;Console&quot; _
551 , &quot;ConsoleClear&quot; _
552 , &quot;ConsoleToFile&quot; _
553 , &quot;DebugPrint&quot; _
554 , &quot;Raise&quot; _
555 , &quot;RaiseAbort&quot; _
556 , &quot;RaiseFatal&quot; _
557 , &quot;RaiseWarning&quot; _
560 End Function &apos; ScriptForge.SF_Exception.Methods
562 REM -----------------------------------------------------------------------------
563 Public Function Properties() As Variant
564 &apos;&apos;&apos; Return the list or properties of the Timer class as an array
566 Properties = Array( _
567 &quot;Description&quot; _
568 , &quot;Number&quot; _
569 , &quot;Source&quot; _
572 End Function &apos; ScriptForge.SF_Exception.Properties
574 REM -----------------------------------------------------------------------------
575 Public Sub PythonPrint(ParamArray pvArgs() As Variant)
576 &apos;&apos;&apos; Display the list of arguments in a readable form in the Python console
577 &apos;&apos;&apos; Arguments are separated by a TAB character (simulated by spaces)
578 &apos;&apos;&apos; The maximum length of each individual argument = 1024 characters
579 &apos;&apos;&apos; Args:
580 &apos;&apos;&apos; Any number of arguments of any type
581 &apos;&apos;&apos; Examples:
582 &apos;&apos;&apos; SF_Exception.PythonPrint(a, Array(1, 2, 3), , &quot;line1&quot; &amp; Chr(10) &amp; &quot;Line2&quot;, DateSerial(2020, 04, 09))
584 Dim sOutput As String &apos; Line to write in console
585 Dim sArg As String &apos; Single argument
586 Dim i As Integer
587 Const cstTab = 4
588 Const cstMaxLength = 1024
589 Const cstPyHelper = &quot;$&quot; &amp; &quot;_SF_Exception__PythonPrint&quot;
590 Const cstThisSub = &quot;Exception.PythonPrint&quot;
591 Const cstSubArgs = &quot;Arg0, [Arg1, ...]&quot;
593 &apos; Save Err, Erl, .. values before any On Error ... statement
594 SF_Exception._CaptureSystemError()
595 If SF_Utils._ErrorHandling() Then On Local Error Goto Finally &apos; Never interrupt processing
596 SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
597 Try:
598 &apos; Build new console line
599 sOutput = &quot;&quot;
600 For i = 0 To UBound(pvArgs)
601 If IsError(pvArgs(i)) Then pvArgs(i) = &quot;&quot;
602 sArg = Iif(i = 0, &quot;&quot;, SF_String.sfTAB) &amp; SF_Utils._Repr(pvArgs(i), cstMaxLength)
603 sOutput = sOutput &amp; sArg
604 Next i
606 &apos; Add to actual console
607 sOutput = SF_String.ExpandTabs(sOutput, cstTab)
608 _SF_._AddToConsole(sOutput)
609 &apos; Display the message in the Python shell console
610 With ScriptForge.SF_Session
611 .ExecutePythonScript(.SCRIPTISSHARED, _SF_.PythonHelper &amp; cstPyHelper, sOutput)
612 End With
614 Finally:
615 SF_Utils._ExitFunction(cstThisSub)
616 Exit Sub
617 End Sub &apos; ScriptForge.SF_Exception.PythonPrint
619 REM -----------------------------------------------------------------------------
620 Public Sub Raise(Optional ByVal Number As Variant _
621 , Optional ByVal Source As Variant _
622 , Optional ByVal Description As Variant _
624 &apos;&apos;&apos; Generate a run-time error. An error message is displayed to the user and logged
625 &apos;&apos;&apos; in the console. The execution is STOPPED
626 &apos;&apos;&apos; Args:
627 &apos;&apos;&apos; Number: the error number, may be numeric or string
628 &apos;&apos;&apos; If numeric and &lt;= 2000, it is considered a LibreOffice Basic run-time error (default = Err)
629 &apos;&apos;&apos; Source: the line where the error occurred (default = Erl) or any string describing the location of the error
630 &apos;&apos;&apos; Description: the error message to log in the console and to display to the user
631 &apos;&apos;&apos; Examples:
632 &apos;&apos;&apos; On Local Error GoTo Catch
633 &apos;&apos;&apos; &apos; ...
634 &apos;&apos;&apos; Catch:
635 &apos;&apos;&apos; SF_Exception.Raise() &apos; Standard behaviour
636 &apos;&apos;&apos; SF_Exception.Raise(11) &apos; Force division by zero
637 &apos;&apos;&apos; SF_Exception.Raise(&quot;MYAPPERROR&quot;, &quot;myFunction&quot;, &quot;Application error&quot;)
638 &apos;&apos;&apos; SF_Exception.Raise(,, &quot;To divide by zero is not a good idea !&quot;)
640 Dim sMessage As String &apos; Error message to log and to display
641 Dim L10N As Object &apos; Alias to LocalizedInterface
642 Const cstThisSub = &quot;Exception.Raise&quot;
643 Const cstSubArgs = &quot;[Number=Err], [Source=Erl], [Description]&quot;
645 &apos; Save Err, Erl, .. values before any On Error ... statement
646 SF_Exception._CaptureSystemError()
647 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
649 Check:
650 If IsMissing(Number) Or IsEmpty(Number) Then Number = -1
651 If IsMissing(Source) Or IsEmpty(Source) Then Source = -1
652 If IsMissing(Description) Or IsEmpty(Description) Then Description = &quot;&quot;
653 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
654 If Not SF_Utils._Validate(Number, &quot;Number&quot;, Array(V_STRING, V_NUMERIC)) Then GoTo Finally
655 If Not SF_Utils._Validate(Source, &quot;Source&quot;, Array(V_STRING, V_NUMERIC)) Then GoTo Finally
656 If Not SF_Utils._Validate(Description, &quot;Description&quot;, V_STRING) Then GoTo Finally
657 End If
659 Try:
660 With SF_Exception
661 If Number &gt;= 0 Then .Number = Number
662 If VarType(Source) = V_STRING Then
663 If Len(Source) &gt; 0 Then .Source = Source
664 ElseIf Source &gt;= 0 Then &apos; -1 = Default =&gt; no change
665 .Source = Source
666 End If
667 If Len(Description) &gt; 0 Then .Description = Description
669 &apos; Log and display
670 Set L10N = _SF_._GetLocalizedInterface()
671 sMessage = L10N.GetText(&quot;LONGERRORDESC&quot;, .Number, .Source, .Description)
672 .DebugPrint(sMessage)
673 If _SF_.DisplayEnabled Then MsgBox L10N.GetText(&quot;ERRORNUMBER&quot;, .Number) _
674 &amp; SF_String.sfNewLine &amp; L10N.GetText(&quot;ERRORLOCATION&quot;, .Source) _
675 &amp; SF_String.sfNewLine &amp; .Description _
676 , MB_OK + MB_ICONSTOP _
677 , L10N.GetText(&quot;ERRORNUMBER&quot;, .Number)
678 End With
680 Finally:
681 SF_Utils._ExitFunction(cstThisSub)
682 If _SF_.StopWhenError Then
683 SF_Exception.Clear()
684 _SF_._StackReset()
685 Stop
686 End If
687 Exit Sub
688 Catch:
689 GoTo Finally
690 End Sub &apos; ScriptForge.SF_Exception.Raise
692 REM -----------------------------------------------------------------------------
693 Public Sub RaiseAbort(Optional ByVal Source As Variant)
694 &apos;&apos;&apos; Manage a run-time error that occurred inside the ScriptForge piece of software itself.
695 &apos;&apos;&apos; The event is logged.
696 &apos;&apos;&apos; The execution is STOPPED
697 &apos;&apos;&apos; For INTERNAL USE only
698 &apos;&apos;&apos; Args:
699 &apos;&apos;&apos; Source: the line where the error occurred
701 Dim sLocation As String &apos; Common header in error messages: location of error
702 Dim vLocation As Variant &apos; Split array (library, module, method)
703 Dim sMessage As String &apos; Error message to log and to display
704 Dim L10N As Object &apos; Alias to LocalizedInterface
705 Const cstTabSize = 4
706 Const cstThisSub = &quot;Exception.RaiseAbort&quot;
707 Const cstSubArgs = &quot;[Source=Erl]&quot;
709 &apos; Save Err, Erl, .. values before any On Error ... statement
710 SF_Exception._CaptureSystemError()
711 On Local Error Resume Next
713 Check:
714 If IsMissing(Source) Or IsEmpty(Source) Then Source = &quot;&quot;
716 Try:
717 With SF_Exception
719 &apos; Prepare message header
720 Set L10N = _SF_._GetLocalizedInterface()
721 If Len(_SF_.MainFunction) &gt; 0 Then &apos; MainFunction = [Library.]Module.Method
722 vLocation = Split(_SF_.MainFunction, &quot;.&quot;)
723 If UBound(vLocation) &lt; 2 Then vLocation = Split(&quot;ScriptForge.&quot; &amp; _SF_.MainFunction, &quot;.&quot;)
724 sLocation = L10N.GetText(&quot;VALIDATESOURCE&quot;, vLocation(0), vLocation(1), vLocation(2)) &amp; &quot;\n\n\n&quot;
725 Else
726 sLocation = &quot;&quot;
727 End If
729 &apos; Log and display
730 sMessage = L10N.GetText(&quot;LONGERRORDESC&quot;, .Number, .Source, .Description)
731 .DebugPrint(sMessage)
732 If _SF_.DisplayEnabled Then
733 sMessage = sLocation _
734 &amp; L10N.GetText(&quot;INTERNALERROR&quot;) _
735 &amp; L10N.GetText(&quot;ERRORLOCATION&quot;, Source &amp; &quot;/&quot; &amp; .Source) &amp; SF_String.sfNewLine &amp; .Description _
736 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; L10N.GetText(&quot;STOPEXECUTION&quot;)
737 MsgBox SF_String.ExpandTabs(SF_String.Unescape(sMessage), cstTabSize) _
738 , MB_OK + MB_ICONSTOP _
739 , L10N.GetText(&quot;ERRORNUMBER&quot;, .Number)
740 End If
742 .Clear()
743 End With
745 Finally:
746 _SF_._StackReset()
747 If _SF_.StopWhenError Then Stop
748 Exit Sub
749 Catch:
750 GoTo Finally
751 End Sub &apos; ScriptForge.SF_Exception.RaiseAbort
753 REM -----------------------------------------------------------------------------
754 Public Sub RaiseFatal(Optional ByVal ErrorCode As Variant _
755 , ParamArray pvArgs _
757 &apos;&apos;&apos; Generate a run-time error caused by an anomaly in a user script detected by ScriptForge
758 &apos;&apos;&apos; The message is logged in the console. The execution is STOPPED
759 &apos;&apos;&apos; For INTERNAL USE only
760 &apos;&apos;&apos; Args:
761 &apos;&apos;&apos; ErrorCode: as a string, the unique identifier of the error
762 &apos;&apos;&apos; pvArgs: the arguments to insert in the error message
764 Dim sLocation As String &apos; Common header in error messages: location of error
765 Dim sService As String &apos; Service name having detected the error
766 Dim sMethod As String &apos; Method name having detected the error
767 Dim vLocation As Variant &apos; Split array (library, module, method)
768 Dim sMessage As String &apos; Message to log and display
769 Dim L10N As Object &apos; Alias of LocalizedInterface
770 Dim sAlt As String &apos; Alternative error messages
771 Dim iButtons As Integer &apos; MB_OK or MB_YESNO
772 Dim iMsgBox As Integer &apos; Return value of the message box
774 Const cstTabSize = 4
775 Const cstThisSub = &quot;Exception.RaiseFatal&quot;
776 Const cstSubArgs = &quot;ErrorCode, [Arg0[, Arg1 ...]]&quot;
777 Const cstStop = &quot;&quot; &apos; Chr(9211)
779 &apos; Save Err, Erl, .. values before any On Error ... statement
780 SF_Exception._CaptureSystemError()
781 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
783 Check:
784 If IsMissing(ErrorCode) Or IsEmpty(ErrorCode) Then ErrorCode = &quot;&quot;
785 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
786 If Not SF_Utils._Validate(ErrorCode, &quot;ErrorCode&quot;, V_STRING) Then GoTo Finally
787 End If
789 Try:
790 Set L10N = _SF_._GetLocalizedInterface()
791 &apos; Location header common to all error messages
792 If Len(_SF_.MainFunction) &gt; 0 Then &apos; MainFunction = [Library.]Module.Method
793 vLocation = Split(_SF_.MainFunction, &quot;.&quot;)
794 If UBound(vLocation) &lt; 2 Then vLocation = Split(&quot;ScriptForge.&quot; &amp; _SF_.MainFunction, &quot;.&quot;)
795 sService = vLocation(1)
796 sMethod = vLocation(2)
797 sLocation = L10N.GetText(&quot;VALIDATESOURCE&quot;, vLocation(0), sService, sMethod) _
798 &amp; &quot;\n&quot; &amp; L10N.GetText(&quot;VALIDATEARGS&quot;, _RightCaseArgs(_SF_.MainFunctionArgs))
799 Else
800 sService = &quot;&quot;
801 sMethod = &quot;&quot;
802 sLocation = &quot;&quot;
803 End If
805 With L10N
806 Select Case UCase(ErrorCode)
807 Case MISSINGARGERROR &apos; SF_Utils._Validate(Name)
808 pvArgs(0) = _RightCase(pvArgs(0))
809 sMessage = sLocation _
810 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
811 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEMISSING&quot;, pvArgs(0))
812 Case ARGUMENTERROR &apos; SF_Utils._Validate(Value, Name, Types, Values, CaseSensitive, Class)
813 pvArgs(1) = _RightCase(pvArgs(1))
814 sMessage = sLocation _
815 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(1)) _
816 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATIONRULES&quot;)
817 If Len(pvArgs(2)) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATETYPES&quot;, pvArgs(1), pvArgs(2))
818 If Len(pvArgs(3)) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEVALUES&quot;, pvArgs(1), pvArgs(3))
819 If Len(pvArgs(5)) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATECLASS&quot;, pvArgs(1), pvArgs(5))
820 sMessage = sMessage &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEACTUAL&quot;, pvArgs(1), pvArgs(0))
821 Case ARRAYERROR &apos; SF_Utils._ValidateArray(Value, Name, Dimensions, Types, NotNull)
822 pvArgs(1) = _RightCase(pvArgs(1))
823 sMessage = sLocation _
824 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(1)) _
825 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATIONRULES&quot;) _
826 &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEARRAY&quot;, pvArgs(1))
827 If pvArgs(2) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEDIMS&quot;, pvArgs(1), pvArgs(2))
828 If Len(pvArgs(3)) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEALLTYPES&quot;, pvArgs(1), pvArgs(3))
829 If pvArgs(4) Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATENOTNULL&quot;, pvArgs(1))
830 sMessage = sMessage &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEACTUAL&quot;, pvArgs(1), pvArgs(0))
831 Case FILEERROR &apos; SF_Utils._ValidateFile(Value, Name, WildCards)
832 pvArgs(1) = _RightCase(pvArgs(1))
833 sMessage = sLocation _
834 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(1)) _
835 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATIONRULES&quot;) _
836 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEFILE&quot;, pvArgs(1))
837 sAlt = &quot;VALIDATEFILE&quot; &amp; SF_FileSystem.FileNaming
838 sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(sAlt, pvArgs(1))
839 If pvArgs(2) Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEWILDCARD&quot;, pvArgs(1))
840 sMessage = sMessage &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEACTUAL&quot;, pvArgs(1), pvArgs(0))
841 Case ARRAYSEQUENCEERROR &apos; SF_Array.RangeInit(From, UpTo, ByStep)
842 sMessage = sLocation _
843 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;ARRAYSEQUENCE&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
844 Case ARRAYINSERTERROR &apos; SF_Array.AppendColumn/Row/PrependColumn/Row(VectorName, Array_2D, Vector)
845 sMessage = sLocation _
846 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;ARRAYINSERT&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
847 Case ARRAYINDEX1ERROR &apos; SF_Array.ExtractColumn/Row(IndexName, Array_2D, Index)
848 sMessage = sLocation _
849 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;ARRAYINDEX1&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
850 Case ARRAYINDEX2ERROR &apos; SF_Array.Slice(From, UpTo)
851 sMessage = sLocation _
852 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;ARRAYINDEX2&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
853 Case CSVPARSINGERROR &apos; SF_Array.ImportFromCSVFile(FileName, LineNumber, Line)
854 sMessage = sLocation _
855 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CSVPARSING&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
856 Case DUPLICATEKEYERROR &apos; SF_Dictionary.Add/ReplaceKey(&quot;Key&quot;, Key)
857 sMessage = sLocation _
858 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
859 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DUPLICATEKEY&quot;, pvArgs(0), pvArgs(1))
860 Case UNKNOWNKEYERROR &apos; SF_Dictionary.Remove/ReplaceItem/ReplaceKey(&quot;Key&quot;, Key)
861 sMessage = sLocation _
862 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
863 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNKNOWNKEY&quot;, pvArgs(0), pvArgs(1))
864 Case INVALIDKEYERROR &apos; SF_Dictionary.Add/ReplaceKey(Key)
865 sMessage = sLocation _
866 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
867 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;INVALIDKEY&quot;)
868 Case UNKNOWNFILEERROR &apos; SF_FileSystem.CopyFile/MoveFile/DeleteFile/CreateScriptService(&quot;L10N&quot;)(ArgName, Filename)
869 pvArgs(0) = _RightCase(pvArgs(0))
870 sMessage = sLocation _
871 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
872 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNKNOWNFILE&quot;, pvArgs(0), pvArgs(1))
873 Case UNKNOWNFOLDERERROR &apos; SF_FileSystem.CopyFolder/MoveFolder/DeleteFolder/Files/SubFolders(ArgName, Filename)
874 pvArgs(0) = _RightCase(pvArgs(0))
875 sMessage = sLocation _
876 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
877 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNKNOWNFOLDER&quot;, pvArgs(0), pvArgs(1))
878 Case NOTAFILEERROR &apos; SF_FileSystem.CopyFile/MoveFile/DeleteFile(ArgName, Filename)
879 pvArgs(0) = _RightCase(pvArgs(0))
880 sMessage = sLocation _
881 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
882 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;NOTAFILE&quot;, pvArgs(0), pvArgs(1))
883 Case NOTAFOLDERERROR &apos; SF_FileSystem.CopyFolder/MoveFolder/DeleteFolder/Files/SubFolders(ArgName, Filename)
884 pvArgs(0) = _RightCase(pvArgs(0))
885 sMessage = sLocation _
886 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
887 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;NOTAFOLDER&quot;, pvArgs(0), pvArgs(1))
888 Case OVERWRITEERROR &apos; SF_FileSystem.Copy+Move/File+Folder/CreateTextFile/OpenTextFile(ArgName, Filename)
889 pvArgs(0) = _RightCase(pvArgs(0))
890 sMessage = sLocation _
891 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
892 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;OVERWRITE&quot;, pvArgs(0), pvArgs(1))
893 Case READONLYERROR &apos; SF_FileSystem.Copy+Move+Delete/File+Folder(ArgName, Filename)
894 pvArgs(0) = _RightCase(pvArgs(0))
895 sMessage = sLocation _
896 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
897 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;READONLY&quot;, pvArgs(0), pvArgs(1))
898 Case NOFILEMATCHERROR &apos; SF_FileSystem.Copy+Move+Delete/File+Folder(ArgName, Filename)
899 pvArgs(0) = _RightCase(pvArgs(0))
900 sMessage = sLocation _
901 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
902 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;NOFILEMATCH&quot;, pvArgs(0), pvArgs(1))
903 Case FOLDERCREATIONERROR &apos; SF_FileSystem.CreateFolder(ArgName, Filename)
904 pvArgs(0) = _RightCase(pvArgs(0))
905 sMessage = sLocation _
906 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
907 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FOLDERCREATION&quot;, pvArgs(0), pvArgs(1))
908 Case FILESYSTEMERROR &apos; SF_FileSystem.---(ArgName, MethodName, ArgValue)
909 pvArgs(0) = _RightCase(pvArgs(0))
910 sMessage = sLocation _
911 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FILESYSTEM&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
912 Case UNKNOWNSERVICEERROR &apos; SF_Services.CreateScriptService(ArgName, Value, Library, Service)
913 pvArgs(0) = _RightCase(pvArgs(0))
914 sMessage = sLocation _
915 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
916 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNKNOWNSERVICE&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
917 Case SERVICESNOTLOADEDERROR &apos; SF_Services.CreateScriptService(ArgName, Value, Library)
918 pvArgs(0) = _RightCase(pvArgs(0))
919 sMessage = sLocation _
920 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
921 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SERVICESNOTLOADED&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
922 Case CALCFUNCERROR &apos; SF_Session.ExecuteCalcFunction(CalcFunction)
923 sMessage = sLocation _
924 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, _RightCase(&quot;CalcFunction&quot;)) _
925 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CALCFUNC&quot;, pvArgs(0))
926 Case NOSCRIPTERROR &apos; SF_Session._GetScript(Language, &quot;Scope&quot;, Scope, &quot;Script&quot;, Script)
927 pvArgs(1) = _RightCase(pvArgs(1)) : pvArgs(3) = _RightCase(pvArgs(3))
928 sMessage = sLocation _
929 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, _RightCase(&quot;Script&quot;)) _
930 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;NOSCRIPT&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4))
931 Case SCRIPTEXECERROR &apos; SF_Session.ExecuteBasicScript(&quot;Script&quot;, Script, Cause)
932 pvArgs(0) = _RightCase(pvArgs(0))
933 sMessage = sLocation _
934 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SCRIPTEXEC&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
935 Case WRONGEMAILERROR &apos; SF_Session.SendMail(Arg, Email)
936 pvArgs(0) = _RightCase(pvArgs(0))
937 sMessage = sLocation _
938 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
939 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;WRONGEMAIL&quot;, pvArgs(1))
940 Case SENDMAILERROR &apos; SF_Session.SendMail()
941 sMessage = sLocation _
942 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SENDMAIL&quot;)
943 Case FILENOTOPENERROR &apos; SF_TextStream._IsFileOpen(FileName)
944 sMessage = sLocation _
945 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FILENOTOPEN&quot;, pvArgs(0))
946 Case FILEOPENMODEERROR &apos; SF_TextStream._IsFileOpen(FileName)
947 sMessage = sLocation _
948 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FILEOPENMODE&quot;, pvArgs(0), pvArgs(1))
949 Case ENDOFFILEERROR &apos; SF_TextStream.ReadLine/ReadAll/SkipLine(FileName)
950 sMessage = sLocation _
951 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;ENDOFFILE&quot;, pvArgs(0))
952 Case DOCUMENTERROR &apos; SF_UI.GetDocument(ArgName, WindowName)
953 pvArgs(0) = _RightCase(pvArgs(0))
954 sMessage = sLocation _
955 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
956 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENT&quot;, pvArgs(0), pvArgs(1))
957 Case DOCUMENTCREATIONERROR &apos; SF_UI.Create(Arg1Name, DocumentType, Arg2Name, TemplateFile)
958 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
959 sMessage = sLocation _
960 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENTCREATION&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
961 Case DOCUMENTOPENERROR &apos; SF_UI.OpenDocument(Arg1Name, FileName, Arg2Name, Password, Arg3Name, FilterName)
962 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2)) : pvArgs(4) = _RightCase(pvArgs(4))
963 sMessage = sLocation _
964 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENTOPEN&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4), pvArgs(5))
965 Case BASEDOCUMENTOPENERROR &apos; SF_UI.OpenBaseDocument(Arg1Name, FileName, Arg2Name, RegistrationName)
966 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
967 sMessage = sLocation _
968 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;BASEDOCUMENTOPEN&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
969 Case DOCUMENTDEADERROR &apos; SF_Document._IsStillAlive(FileName)
970 sMessage = sLocation _
971 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENTDEAD&quot;, pvArgs(0))
972 Case DOCUMENTSAVEERROR &apos; SF_Document.Save(Arg1Name, FileName)
973 pvArgs(0) = _RightCase(pvArgs(0))
974 sMessage = sLocation _
975 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENTSAVE&quot;, pvArgs(0), pvArgs(1))
976 Case DOCUMENTSAVEASERROR &apos; SF_Document.SaveAs(Arg1Name, FileName, Arg2, Overwrite, Arg3, FilterName)
977 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2)) : pvArgs(4) = _RightCase(pvArgs(4))
978 sMessage = sLocation _
979 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENTSAVEAS&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4), pvArgs(5))
980 Case DOCUMENTREADONLYERROR &apos; SF_Document.update property(&quot;Document&quot;, FileName)
981 pvArgs(0) = _RightCase(pvArgs(0))
982 sMessage = sLocation _
983 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENTREADONLY&quot;, pvArgs(0), pvArgs(1))
984 Case DBCONNECTERROR &apos; SF_Base.GetDatabase(&quot;User&quot;, User, &quot;Password&quot;, Password, FileName)
985 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
986 sMessage = sLocation _
987 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DBCONNECT&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4))
988 Case CALCADDRESSERROR &apos; SF_Calc._ParseAddress(Address, &quot;Range&quot;/&quot;Sheet&quot;, Scope, Document)
989 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
990 sMessage = sLocation _
991 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
992 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CALCADDRESS&quot; &amp; Iif(Left(pvArgs(0), 5) = &quot;Sheet&quot;, &quot;1&quot;, &quot;2&quot;), pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
993 Case DUPLICATESHEETERROR &apos; SF_Calc.InsertSheet(arg, SheetName, Document)
994 pvArgs(0) = _RightCase(pvArgs(0))
995 sMessage = sLocation _
996 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
997 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DUPLICATESHEET&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
998 Case OFFSETADDRESSERROR &apos; SF_Calc.RangeOffset(&quot;Range&quot;, Range, &quot;Rows&quot;, Rows, &quot;Columns&quot;, Columns, &quot;Height&quot;, Height, &quot;Width&quot;, Width, &quot;Document, Document)
999 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2)) : pvArgs(4) = _RightCase(pvArgs(4))
1000 pvArgs(6) = _RightCase(pvArgs(6)) : pvArgs(8) = _RightCase(pvArgs(8)) : pvArgs(10) = _RightCase(pvArgs(10))
1001 sMessage = sLocation _
1002 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;OFFSETADDRESS&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4) _
1003 , pvArgs(5), pvArgs(6), pvArgs(7), pvArgs(8), pvArgs(9), pvArgs(10), pvArgs(11))
1004 Case DUPLICATECHARTERROR &apos; SF_Calc.CreateChart(chart, ChartName, sheet, SheetName, Document, file)
1005 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
1006 sMessage = sLocation _
1007 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
1008 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DUPLICATECHART&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4), pvArgs(5))
1009 Case RANGEEXPORTERROR &apos; SF_Calc.ExportRangeToFile(Arg1Name, FileName, Arg2, Overwrite)
1010 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
1011 sMessage = sLocation _
1012 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;RANGEEXPORT&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
1013 Case CHARTEXPORTERROR &apos; SF_Chart.ExportToFile(Arg1Name, FileName, Arg2, Overwrite)
1014 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
1015 sMessage = sLocation _
1016 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CHARTEXPORT&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
1017 Case FORMDEADERROR &apos; SF_Form._IsStillAlive(FormName, DocumentName)
1018 sMessage = sLocation _
1019 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FORMDEAD&quot;, pvArgs(0), pvArgs(1))
1020 Case CALCFORMNOTFOUNDERROR &apos; SF_Calc.Forms(Index, SheetName, Document)
1021 sMessage = sLocation _
1022 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CALCFORMNOTFOUND&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
1023 Case WRITERFORMNOTFOUNDERROR &apos; SF_Document.Forms(Index, Document)
1024 sMessage = sLocation _
1025 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;WRITERFORMNOTFOUND&quot;, pvArgs(0), pvArgs(1))
1026 Case BASEFORMNOTFOUNDERROR &apos; SF_Base.Forms(Index, FormDocument, BaseDocument)
1027 sMessage = sLocation _
1028 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;BASEFORMNOTFOUND&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
1029 Case SUBFORMNOTFOUNDERROR &apos; SF_Form.Subforms(Subform, Mainform)
1030 sMessage = sLocation _
1031 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SUBFORMNOTFOUND&quot;, pvArgs(0), pvArgs(1))
1032 Case FORMCONTROLTYPEERROR &apos; SF_FormControl._SetProperty(ControlName, FormName, ControlType, Property)
1033 sMessage = sLocation _
1034 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FORMCONTROLTYPE&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
1035 Case WRITERRANGEERROR &apos; SF_Writer._ParseRange(TextRange, &quot;TextRange&quot;, Scope, Document)
1036 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
1037 sMessage = sLocation _
1038 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
1039 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;WRITERRANGE&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
1040 Case DIALOGNOTFOUNDERROR &apos; SF_Dialog._NewDialog(Service, DialogName, WindowName)
1041 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2)) : pvArgs(4) = _RightCase(pvArgs(4))
1042 pvArgs(6) = _RightCase(pvArgs(6))
1043 sMessage = sLocation _
1044 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DIALOGNOTFOUND&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4) _
1045 , pvArgs(5), pvArgs(6), pvArgs(7))
1046 Case DIALOGDEADERROR &apos; SF_Dialog._IsStillAlive(DialogName)
1047 sMessage = sLocation _
1048 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DIALOGDEAD&quot;, pvArgs(0))
1049 Case CONTROLTYPEERROR &apos; SF_DialogControl._SetProperty(ControlName, DialogName, ControlType, Property)
1050 sMessage = sLocation _
1051 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CONTROLTYPE&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
1052 Case TEXTFIELDERROR &apos; SF_DialogControl.WriteLine(ControlName, DialogName)
1053 sMessage = sLocation _
1054 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;TEXTFIELD&quot;, pvArgs(0), pvArgs(1))
1055 Case PAGEMANAGERERROR &apos; SF_Dialog.SetPageManager(PilotsList, TabsList, WizardsList)
1056 sMessage = sLocation _
1057 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;PAGEMANAGER&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4), pvArgs(5))
1058 Case DUPLICATECONTROLERROR &apos; SF_Dialog.CreateControl(ControlName, DialogName)
1059 pvArgs(0) = _RightCase(pvArgs(0))
1060 sMessage = sLocation _
1061 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
1062 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DUPLICATECONTROL&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
1063 Case DBREADONLYERROR &apos; SF_Database.RunSql(), SF_Dataset.Delete(), Insert(), Update()
1064 sMessage = sLocation _
1065 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DBREADONLY&quot;, vLocation(2))
1066 Case SQLSYNTAXERROR &apos; SF_Database._ExecuteSql(SQL)
1067 sMessage = sLocation _
1068 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SQLSYNTAX&quot;, pvArgs(0))
1069 Case SQLSYNTAX2ERROR &apos; SF_Dataset.Reload/_Initialize(SQL, Filter, OrderBy)
1070 sMessage = sLocation _
1071 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SQLSYNTAX2&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
1072 Case NOCURRENTRECORDERROR &apos; SF_Dataset.Insert/Update/GetValue/Delete
1073 sMessage = sLocation _
1074 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;NOCURRENTRECORD&quot;)
1075 Case RECORDUPDATEERROR &apos; SF_Dataset.Insert/Update(FieldName, FieldValue, FieldType)
1076 sMessage = sLocation _
1077 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;RECORDUPDATE&quot;, pvArgs(0), pvArgs(1), pvARgs(2))
1078 Case FIELDEXPORTERROR &apos; SF_Dataset.ExportFieldToFile(Arg1Name, FileName, Arg2, Overwrite)
1079 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
1080 sMessage = sLocation _
1081 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FIELDEXPORT&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
1082 Case PYTHONSHELLERROR &apos; SF_Exception.PythonShell (Python only)
1083 sMessage = sLocation _
1084 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;PYTHONSHELL&quot;)
1085 Case UNITTESTLIBRARYERROR &apos; SFUnitTests._NewUnitTest(LibraryName)
1086 sMessage = sLocation _
1087 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNITTESTLIBRARY&quot;, pvArgs(0))
1088 Case UNITTESTMETHODERROR &apos; SFUnitTests.SF_UnitTest(Method)
1089 sMessage = sLocation _
1090 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNITTESTMETHOD&quot;, pvArgs(0))
1091 Case Else
1092 End Select
1093 End With
1095 &apos; Log fatal event
1096 _SF_._AddToConsole(sMessage)
1098 &apos; Display fatal event, if relevant (default)
1099 If _SF_.DisplayEnabled Then
1100 If _SF_.StopWhenError Then sMessage = sMessage &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; L10N.GetText(&quot;STOPEXECUTION&quot;)
1101 &apos; Do you need more help ?
1102 If Len(sMethod) &gt; 0 Then
1103 sMessage = sMessage &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; L10N.GetText(&quot;NEEDMOREHELP&quot;, sMethod)
1104 iButtons = MB_YESNO + MB_DEFBUTTON2
1105 Else
1106 iButtons = MB_OK
1107 End If
1108 iMsgBox = MsgBox(SF_String.ExpandTabs(SF_String.Unescape(sMessage), cstTabSize) _
1109 , iButtons + MB_ICONEXCLAMATION _
1110 , L10N.GetText(&quot;ERRORNUMBER&quot;, ErrorCode) _
1112 &apos; If more help needed ...
1113 If iMsgBox = IDYES Then _OpenHelpInBrowser(sService, sMethod)
1114 End If
1116 Finally:
1117 SF_Utils._ExitFunction(cstThisSub)
1118 _SF_._StackReset()
1119 If _SF_.StopWhenError Then Stop
1120 Exit Sub
1121 Catch:
1122 GoTo Finally
1123 End Sub &apos; ScriptForge.SF_Exception.RaiseFatal
1125 REM -----------------------------------------------------------------------------
1126 Public Sub RaiseWarning(Optional ByVal Number As Variant _
1127 , Optional ByVal Source As Variant _
1128 , Optional ByVal Description As Variant _
1130 &apos;&apos;&apos; Generate a run-time error. An error message is displayed to the user and logged
1131 &apos;&apos;&apos; in the console. The execution is NOT STOPPED
1132 &apos;&apos;&apos; Args:
1133 &apos;&apos;&apos; Number: the error number, may be numeric or string
1134 &apos;&apos;&apos; If numeric and &lt;= 2000, it is considered a LibreOffice Basic run-time error (default = Err)
1135 &apos;&apos;&apos; Source: the line where the error occurred (default = Erl) or any string describing the location of the error
1136 &apos;&apos;&apos; Description: the error message to log in the console and to display to the user
1137 &apos;&apos;&apos; Returns:
1138 &apos;&apos;&apos; True if successful. Anyway, the execution continues
1139 &apos;&apos;&apos; Examples:
1140 &apos;&apos;&apos; On Local Error GoTo Catch
1141 &apos;&apos;&apos; &apos; ...
1142 &apos;&apos;&apos; Catch:
1143 &apos;&apos;&apos; SF_Exception.RaiseWarning() &apos; Standard behaviour
1144 &apos;&apos;&apos; SF_Exception.RaiseWarning(11) &apos; Force division by zero
1145 &apos;&apos;&apos; SF_Exception.RaiseWarning(&quot;MYAPPERROR&quot;, &quot;myFunction&quot;, &quot;Application error&quot;)
1146 &apos;&apos;&apos; SF_Exception.RaiseWarning(,, &quot;To divide by zero is not a good idea !&quot;)
1148 Dim bStop As Boolean &apos; Alias for stop switch
1149 Const cstThisSub = &quot;Exception.RaiseWarning&quot;
1150 Const cstSubArgs = &quot;[Number=Err], [Source=Erl], [Description]&quot;
1152 &apos; Save Err, Erl, .. values before any On Error ... statement
1153 SF_Exception._CaptureSystemError()
1154 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1156 Check:
1157 If IsMissing(Number) Or IsEmpty(Number) Then Number = -1
1158 If IsMissing(Source) Or IsEmpty(Source) Then Source = -1
1159 If IsMissing(Description) Or IsEmpty(Description) Then Description = &quot;&quot;
1160 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1161 If Not SF_Utils._Validate(Number, &quot;Number&quot;, Array(V_STRING, V_NUMERIC, V_EMPTY)) Then GoTo Finally
1162 If Not SF_Utils._Validate(Source, &quot;Source&quot;, Array(V_STRING, V_NUMERIC, V_EMPTY)) Then GoTo Finally
1163 If Not SF_Utils._Validate(Description, &quot;Description&quot;, V_STRING) Then GoTo Finally
1164 End If
1166 Try:
1167 bStop = _SF_.StopWhenError &apos; Store current value to reset it before leaving the Sub
1168 _SF_.StopWhenError = False
1169 SF_Exception.Raise(Number, Source, Description)
1171 Finally:
1172 SF_Utils._ExitFunction(cstThisSub)
1173 _SF_.StopWhenError = bStop
1174 Exit Sub
1175 Catch:
1176 GoTo Finally
1177 End Sub &apos; ScriptForge.SF_Exception.RaiseWarning
1179 REM -----------------------------------------------------------------------------
1180 Public Function SetProperty(Optional ByVal PropertyName As Variant _
1181 , Optional ByRef Value As Variant _
1182 ) As Boolean
1183 &apos;&apos;&apos; Set a new value to the given property
1184 &apos;&apos;&apos; Args:
1185 &apos;&apos;&apos; PropertyName: the name of the property as a string
1186 &apos;&apos;&apos; Value: its new value
1187 &apos;&apos;&apos; Exceptions
1188 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
1190 Const cstThisSub = &quot;Exception.SetProperty&quot;
1191 Const cstSubArgs = &quot;PropertyName, Value&quot;
1193 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1194 SetProperty = False
1196 Check:
1197 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1198 If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
1199 End If
1201 Try:
1202 SetProperty = _PropertySet(PropertyName, Value)
1204 Finally:
1205 SF_Utils._ExitFunction(cstThisSub)
1206 Exit Function
1207 Catch:
1208 GoTo Finally
1209 End Function &apos; ScriptForge.SF_Exception.SetProperty
1211 REM =========================================================== PRIVATE FUNCTIONS
1213 REM -----------------------------------------------------------------------------
1214 Private Sub _CaptureSystemError()
1215 &apos;&apos;&apos; Store system error status in system error properties
1216 &apos;&apos;&apos; Called at each invocation of an error management property or method
1217 &apos;&apos;&apos; Reset by SF_Exception.Clear()
1219 If Err &gt; 0 And _SysNumber = 0 Then
1220 _SysNumber = Err
1221 _SysSource = Erl
1222 _SysDescription = Error$
1223 End If
1225 End Sub &apos; ScriptForge.SF_Exception._CaptureSystemError
1227 REM -----------------------------------------------------------------------------
1228 Public Sub _CloseConsole(Optional ByRef poEvent As Object)
1229 &apos;&apos;&apos; Close the console when opened in non-modal mode
1230 &apos;&apos;&apos; Triggered by the CloseNonModalButton from the dlgConsole dialog
1232 On Local Error GoTo Finally
1234 Try:
1235 With _SF_
1236 If Not IsNull(.ConsoleDialog) Then
1237 If .ConsoleDialog._IsStillAlive(False) Then &apos; False to not raise an error
1238 Set .ConsoleControl = .ConsoleControl.Dispose()
1239 Set .ConsoleDialog = .ConsoleDialog.Dispose()
1240 End If
1241 End If
1242 End With
1244 Finally:
1245 Exit Sub
1246 End Sub &apos; ScriptForge.SF_Exception._CloseConsole
1248 REM -----------------------------------------------------------------------------
1249 Private Sub _ConsoleRefresh()
1250 &apos;&apos;&apos; Reload the content of the console in the dialog
1251 &apos;&apos;&apos; Needed when console first loaded or when totally or partially cleared
1253 With _SF_
1254 &apos; Do nothing if console inactive
1255 If IsNull(.ConsoleDialog) Then GoTo Finally
1256 If Not .ConsoleDialog._IsStillAlive(False) Then &apos; False to not generate an error when dead
1257 Set .ConsoleControl = .ConsoleControl.Dispose()
1258 Set .ConsoleDialog = Nothing
1259 GoTo Finally
1260 End If
1261 &apos; Store the relevant text in the control
1262 If IsNull(.ConsoleControl) Then Set .ConsoleControl = .ConsoleDialog.Controls(CONSOLENAME)
1263 .ConsoleControl.Value = &quot;&quot;
1264 If UBound(.ConsoleLines) &gt;= 0 Then .ConsoleControl.WriteLine(Join(.ConsoleLines, SF_String.sfNEWLINE))
1265 End With
1267 Finally:
1268 Exit Sub
1269 End Sub &apos; ScriptForge.SF_Exception._ConsoleRefresh
1271 REM -----------------------------------------------------------------------------
1272 Private Sub _OpenHelpInBrowser(ByVal psService As String, ByVal psMethod As String)
1273 &apos;&apos;&apos; Open the help page and help anchor related to the given ScriptForge service and method
1275 Dim sUrl As String &apos; URL to open
1276 Const cstURL = &quot;https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_%1.html?&amp;DbPAR=BASIC#%2&quot;
1278 On Local Error GoTo Finally &apos; No reason to risk abort here
1279 Try:
1280 sUrl = SF_String.ReplaceStr(cstURL, Array(&quot;%1&quot;, &quot;%2&quot;), Array(LCase(psService), psMethod))
1281 SF_Session.OpenUrlInBrowser(sUrl)
1283 Finally:
1284 Exit Sub
1285 End Sub &apos; ScriptForge.SF_Exception._OpenHelpInBrowser
1287 REM -----------------------------------------------------------------------------
1288 Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
1289 &apos;&apos;&apos; Return the value of the named property
1290 &apos;&apos;&apos; Args:
1291 &apos;&apos;&apos; psProperty: the name of the property
1293 Dim cstThisSub As String
1294 Const cstSubArgs = &quot;&quot;
1296 cstThisSub = &quot;SF_Exception.get&quot; &amp; psProperty
1298 SF_Exception._CaptureSystemError()
1300 Select Case psProperty
1301 Case &quot;Description&quot;
1302 If _Description = &quot;&quot; Then _PropertyGet = _SysDescription Else _PropertyGet = _Description
1303 Case &quot;Number&quot;
1304 If IsEmpty(_Number) Then _PropertyGet = _SysNumber Else _PropertyGet = _Number
1305 Case &quot;Source&quot;
1306 If IsEmpty(_Source) Then _PropertyGet = _SysSource Else _PropertyGet = _Source
1307 Case Else
1308 _PropertyGet = Null
1309 End Select
1311 Finally:
1312 Exit Function
1313 End Function &apos; ScriptForge.SF_Exception._PropertyGet
1315 REM -----------------------------------------------------------------------------
1316 Private Function _PropertySet(Optional ByVal psProperty As String _
1317 , Optional ByVal pvValue As Variant _
1318 ) As Boolean
1319 &apos;&apos;&apos; Set a new value to the named property
1320 &apos;&apos;&apos; Applicable only to user defined errors
1321 &apos;&apos;&apos; Args:
1322 &apos;&apos;&apos; psProperty: the name of the property
1323 &apos;&apos;&apos; pvValue: the new value
1325 Dim cstThisSub As String
1326 Const cstSubArgs = &quot;&quot;
1328 cstThisSub = &quot;SF_Exception.set&quot; &amp; psProperty
1329 _PropertySet = False
1331 SF_Exception._CaptureSystemError()
1333 &apos; Argument validation must be manual to preserve system error status
1334 &apos; If wrong VarType then property set is ignored
1335 Select Case psProperty
1336 Case &quot;Description&quot;
1337 If VarType(pvValue) = V_STRING Then _Description = pvValue
1338 Case &quot;Number&quot;
1339 Select Case SF_Utils._VarTypeExt(pvValue)
1340 Case V_STRING
1341 _Number = pvValue
1342 Case V_NUMERIC
1343 _Number = CLng(pvValue)
1344 If _Number &lt;= RUNTIMEERRORS And Len(_Description) = 0 Then _Description = Error(_Number)
1345 Case V_EMPTY
1346 _Number = Empty
1347 Case Else
1348 End Select
1349 Case &quot;Source&quot;
1350 Select Case SF_Utils._VarTypeExt(pvValue)
1351 Case V_STRING
1352 _Source = pvValue
1353 Case V_NUMERIC
1354 _Source = CLng(pvValue)
1355 Case Else
1356 End Select
1357 Case Else
1358 End Select
1360 _PropertySet = True
1362 Finally:
1363 Exit Function
1364 End Function &apos; ScriptForge.SF_Exception._PropertySet
1366 REM -----------------------------------------------------------------------------
1367 Private Function _Repr() As String
1368 &apos;&apos;&apos; Convert the Exception instance to a readable string, typically for debugging purposes (DebugPrint ...)
1369 &apos;&apos;&apos; Args:
1370 &apos;&apos;&apos; Return:
1371 &apos;&apos;&apos; &quot;[Exception]: A readable string&quot;
1373 _Repr = &quot;[Exception]: &quot; &amp; _Number &amp; &quot; (&quot; &amp; _Description &amp; &quot;)&quot;
1375 End Function &apos; ScriptForge.SF_Exception._Repr
1377 REM -----------------------------------------------------------------------------
1378 Private Function _RightCase(psString As String) As String
1379 &apos;&apos;&apos; Return the input argument in lower case only when the procedure in execution
1380 &apos;&apos;&apos; has been triggered from a Python script
1381 &apos;&apos;&apos; Indeed, Python requires lower case arguments
1382 &apos;&apos;&apos; Args:
1383 &apos;&apos;&apos; psString: probably an identifier in ProperCase
1384 &apos;&apos;&apos; Return:
1385 &apos;&apos;&apos; The input argument in lower case or left unchanged depending on the execution context
1387 Try:
1388 If _SF_.TriggeredByPython Then _RightCase = LCase(psString) Else _RightCase = psString
1390 Finally:
1391 Exit Function
1392 End Function &apos; ScriptForge.SF_Exception._RightCase
1394 REM -----------------------------------------------------------------------------
1395 Private Function _RightCaseArgs(psString As String) As String
1396 &apos;&apos;&apos; Return the input argument unchanged when the execution context is Basic
1397 &apos;&apos;&apos; When it is Python, the argument names are lowercased.
1398 &apos;&apos;&apos; Args:
1399 &apos;&apos;&apos; psString: one of the cstSubArgs strings located in each official method
1400 &apos;&apos;&apos; Return:
1401 &apos;&apos;&apos; The input string in which the argument names are put in lower case when called from Python scripts
1403 Dim sSubArgs As String &apos; Return value
1404 Dim vArgs As Variant &apos; Input string split on the comma character
1405 Dim sSingleArg As String &apos; Single vArgs item
1406 Dim vSingleArgs As Variant &apos; vSingleArg split on equal sign
1407 Dim i As Integer
1409 Const cstComma = &quot;,&quot;
1410 Const cstEqual = &quot;=&quot;
1412 Try:
1413 If Len(psString) = 0 Then
1414 sSubArgs = &quot;&quot;
1415 ElseIf _SF_.TriggeredByPython Then
1416 vArgs = SF_String.SplitNotQuoted(psString, cstComma, QuoteChar := &quot;&quot;&quot;&quot;)
1417 For i = 0 To UBound(vArgs)
1418 sSingleArg = vArgs(i)
1419 vSingleArgs = Split(sSingleArg, cstEqual)
1420 vSingleArgs(0) = LCase(vSingleArgs(0))
1421 vArgs(i) = join(vSingleArgs, cstEqual)
1422 Next i
1423 sSubArgs = Join(vArgs, cstComma)
1424 Else
1425 sSubArgs = psString
1426 End If
1428 Finally:
1429 _RightCaseArgs = sSubArgs
1430 Exit Function
1431 End Function &apos; ScriptForge.SF_Exception._RightCaseArgs
1433 REM ============================================ END OF SCRIPTFORGE.SF_EXCEPTION
1434 </script:module>