Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / wizards / source / scriptforge / SF_Exception.xba
blob6add0b15899041e6d9e4fd3570b9cad9c12687ea
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;
76 &apos; SF_Services
77 Const UNKNOWNSERVICEERROR = &quot;UNKNOWNSERVICEERROR&quot;
78 Const SERVICESNOTLOADEDERROR = &quot;SERVICESNOTLOADEDERROR&quot;
80 &apos; SF_Session
81 Const CALCFUNCERROR = &quot;CALCFUNCERROR&quot;
82 Const NOSCRIPTERROR = &quot;NOSCRIPTERROR&quot;
83 Const SCRIPTEXECERROR = &quot;SCRIPTEXECERROR&quot;
84 Const WRONGEMAILERROR = &quot;WRONGEMAILERROR&quot;
85 Const SENDMAILERROR = &quot;SENDMAILERROR&quot;
87 &apos; SF_TextStream
88 Const FILENOTOPENERROR = &quot;FILENOTOPENERROR&quot;
89 Const FILEOPENMODEERROR = &quot;FILEOPENMODEERROR&quot;
90 Const ENDOFFILEERROR = &quot;ENDOFFILEERROR&quot;
92 &apos; SF_UI
93 Const DOCUMENTERROR = &quot;DOCUMENTERROR&quot;
94 Const DOCUMENTCREATIONERROR = &quot;DOCUMENTCREATIONERROR&quot;
95 Const DOCUMENTOPENERROR = &quot;DOCUMENTOPENERROR&quot;
96 Const BASEDOCUMENTOPENERROR = &quot;BASEDOCUMENTOPENERROR&quot;
98 &apos; SF_Document
99 Const DOCUMENTDEADERROR = &quot;DOCUMENTDEADERROR&quot;
100 Const DOCUMENTSAVEERROR = &quot;DOCUMENTSAVEERROR&quot;
101 Const DOCUMENTSAVEASERROR = &quot;DOCUMENTSAVEASERROR&quot;
102 Const DOCUMENTREADONLYERROR = &quot;DOCUMENTREADONLYERROR&quot;
103 Const DBCONNECTERROR = &quot;DBCONNECTERROR&quot;
105 &apos; SF_Calc
106 Const CALCADDRESSERROR = &quot;CALCADDRESSERROR&quot;
107 Const DUPLICATESHEETERROR = &quot;DUPLICATESHEETERROR&quot;
108 Const OFFSETADDRESSERROR = &quot;OFFSETADDRESSERROR&quot;
109 Const DUPLICATECHARTERROR = &quot;DUPLICATECHARTERROR&quot;
110 Const RANGEEXPORTERROR = &quot;RANGEEXPORTERROR&quot;
112 &apos; SF_Chart
113 Const CHARTEXPORTERROR = &quot;CHARTEXPORTERROR&quot;
115 &apos; SF_Form
116 Const FORMDEADERROR = &quot;FORMDEADERROR&quot;
117 Const CALCFORMNOTFOUNDERROR = &quot;CALCFORMNOTFOUNDERROR&quot;
118 Const WRITERFORMNOTFOUNDERROR = &quot;WRITERFORMNOTFOUNDERROR&quot;
119 Const BASEFORMNOTFOUNDERROR = &quot;BASEFORMNOTFOUNDERROR&quot;
120 Const SUBFORMNOTFOUNDERROR = &quot;SUBFORMNOTFOUNDERROR&quot;
121 Const FORMCONTROLTYPEERROR = &quot;FORMCONTROLTYPEERROR&quot;
123 &apos; SF_Dialog
124 Const DIALOGNOTFOUNDERROR = &quot;DIALOGNOTFOUNDERROR&quot;
125 Const DIALOGDEADERROR = &quot;DIALOGDEADERROR&quot;
126 Const CONTROLTYPEERROR = &quot;CONTROLTYPEERROR&quot;
127 Const TEXTFIELDERROR = &quot;TEXTFIELDERROR&quot;
128 Const PAGEMANAGERERROR = &quot;PAGEMANAGERERROR&quot;
129 Const DUPLICATECONTROLERROR = &quot;DUPLICATECONTROLERROR&quot;
131 &apos; SF_Database
132 Const DBREADONLYERROR = &quot;DBREADONLYERROR&quot;
133 Const SQLSYNTAXERROR = &quot;SQLSYNTAXERROR&quot;
135 &apos; Python
136 Const PYTHONSHELLERROR = &quot;PYTHONSHELLERROR&quot;
138 &apos; SF_UnitTest
139 Const UNITTESTLIBRARYERROR = &quot;UNITTESTLIBRARYERROR&quot;
140 Const UNITTESTMETHODERROR = &quot;UNITTESTMETHODERROR&quot;
142 REM ============================================================= PRIVATE MEMBERS
144 &apos; User defined errors
145 Private _Number As Variant &apos; Error number/code (Integer or String)
146 Private _Source As Variant &apos; Where the error occurred: a module, a Sub/Function, ...
147 Private _Description As String &apos; The error message
149 &apos; System run-time errors
150 Private _SysNumber As Long &apos; Alias of Err
151 Private _SysSource As Long &apos; Alias of Erl
152 Private _SysDescription As String &apos; Alias of Error$
154 REM ============================================================ MODULE CONSTANTS
156 Const RUNTIMEERRORS = 2000 &apos; Upper limit of Basic run-time errors
157 Const CONSOLENAME = &quot;ConsoleLines&quot; &apos; Name of control in the console dialog
159 REM ===================================================== CONSTRUCTOR/DESTRUCTOR
161 REM -----------------------------------------------------------------------------
162 Public Function Dispose() As Variant
163 Set Dispose = Nothing
164 End Function &apos; ScriptForge.SF_Exception Explicit destructor
166 REM ================================================================== PROPERTIES
168 REM -----------------------------------------------------------------------------
169 Property Get Description() As Variant
170 &apos;&apos;&apos; Returns the description of the last error that has occurred
171 &apos;&apos;&apos; Example:
172 &apos;&apos;&apos; myException.Description
173 Description = _PropertyGet(&quot;Description&quot;)
174 End Property &apos; ScriptForge.SF_Exception.Description (get)
176 REM -----------------------------------------------------------------------------
177 Property Let Description(ByVal pvDescription As Variant)
178 &apos;&apos;&apos; Set the description of the last error that has occurred
179 &apos;&apos;&apos; Example:
180 &apos;&apos;&apos; myException.Description = &quot;Not smart to divide by zero&quot;
181 _PropertySet &quot;Description&quot;, pvDescription
182 End Property &apos; ScriptForge.SF_Exception.Description (let)
184 REM -----------------------------------------------------------------------------
185 Property Get Number() As Variant
186 &apos;&apos;&apos; Returns the code of the last error that has occurred
187 &apos;&apos;&apos; Example:
188 &apos;&apos;&apos; myException.Number
189 Number = _PropertyGet(&quot;Number&quot;)
190 End Property &apos; ScriptForge.SF_Exception.Number (get)
192 REM -----------------------------------------------------------------------------
193 Property Let Number(ByVal pvNumber As Variant)
194 &apos;&apos;&apos; Set the code of the last error that has occurred
195 &apos;&apos;&apos; Example:
196 &apos;&apos;&apos; myException.Number = 11 &apos; Division by 0
197 _PropertySet &quot;Number&quot;, pvNumber
198 End Property &apos; ScriptForge.SF_Exception.Number (let)
200 REM -----------------------------------------------------------------------------
201 Property Get Source() As Variant
202 &apos;&apos;&apos; Returns the location of the last error that has occurred
203 &apos;&apos;&apos; Example:
204 &apos;&apos;&apos; myException.Source
205 Source = _PropertyGet(&quot;Source&quot;)
206 End Property &apos; ScriptForge.SF_Exception.Source (get)
208 REM -----------------------------------------------------------------------------
209 Property Let Source(ByVal pvSource As Variant)
210 &apos;&apos;&apos; Set the location of the last error that has occurred
211 &apos;&apos;&apos; Example:
212 &apos;&apos;&apos; myException.Source = 123 &apos; Line # 123. Source may also be a string
213 _PropertySet &quot;Source&quot;, pvSource
214 End Property &apos; ScriptForge.SF_Exception.Source (let)
216 REM -----------------------------------------------------------------------------
217 Property Get ObjectType As String
218 &apos;&apos;&apos; Only to enable object representation
219 ObjectType = &quot;SF_Exception&quot;
220 End Property &apos; ScriptForge.SF_String.ObjectType
222 REM -----------------------------------------------------------------------------
223 Property Get ServiceName As String
224 &apos;&apos;&apos; Internal use
225 ServiceName = &quot;ScriptForge.Exception&quot;
226 End Property &apos; ScriptForge.SF_Exception.ServiceName
228 REM ===================================================================== METHODS
230 REM -----------------------------------------------------------------------------
231 Public Sub Clear()
232 &apos;&apos;&apos; Reset the current error status and clear the SF_Exception object
233 &apos;&apos;&apos; Args:
234 &apos;&apos;&apos; Examples:
235 &apos;&apos;&apos; On Local Error GoTo Catch
236 &apos;&apos;&apos; &apos; ...
237 &apos;&apos;&apos; Catch:
238 &apos;&apos;&apos; SF_Exception.Clear() &apos; Deny the error
240 Const cstThisSub = &quot;Exception.Clear&quot;
241 Const cstSubArgs = &quot;&quot;
243 Check:
245 Try:
246 With SF_Exception
247 ._Number = Empty
248 ._Source = Empty
249 ._Description = &quot;&quot;
250 ._SysNumber = 0
251 ._SysSource = 0
252 ._SysDescription = &quot;&quot;
253 End With
255 Finally:
256 On Error GoTo 0
257 Exit Sub
258 Catch:
259 GoTo Finally
260 End Sub &apos; ScriptForge.SF_Exception.Clear
262 REM -----------------------------------------------------------------------------
263 Public Sub Console(Optional ByVal Modal As Variant, _
264 Optional ByRef _Context As Variant _
266 &apos;&apos;&apos; Display the console messages in a modal or non-modal dialog
267 &apos;&apos;&apos; If the dialog is already active, when non-modal, it is brought to front
268 &apos;&apos;&apos; Args:
269 &apos;&apos;&apos; Modal: Boolean. Default = True
270 &apos;&apos;&apos; _Context: From Python, the XComponentXontext (FOR INTERNAL USE ONLY)
271 &apos;&apos;&apos; Example:
272 &apos;&apos;&apos; SF_Exception.Console()
274 Dim bConsoleActive As Boolean &apos; When True, dialog is active
275 Dim oModalBtn As Object &apos; Modal close button
276 Dim oNonModalBtn As Object &apos; Non modal close button
277 Const cstThisSub = &quot;Exception.Console&quot;
278 Const cstSubArgs = &quot;[Modal=True]&quot;
280 If SF_Utils._ErrorHandling() Then On Local Error GoTo Finally &apos; Never interrupt processing
282 Check:
283 If IsMissing(Modal) Or IsEmpty(Modal) Then Modal = True
284 If IsMissing(_Context) Or IsEmpty(_Context) Then _Context = Nothing
285 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
286 If Not SF_Utils._Validate(Modal, &quot;Modal&quot;, V_BOOLEAN) Then GoTo Finally
287 End If
289 Try:
290 With _SF_
291 bConsoleActive = False
292 If Not IsNull(.ConsoleDialog) Then bConsoleActive = .ConsoleDialog._IsStillAlive(False) &apos; False to not raise an error
293 If bConsoleActive And Modal = False Then
294 &apos; Bring to front
295 .ConsoleDialog.Activate()
296 Else
297 &apos; Initialize dialog and fill with actual data
298 &apos; The dual modes (modal and non-modal) require to have 2 close buttons o/w only 1 is visible
299 &apos; - a usual OK button
300 &apos; - a Default button triggering the Close action
301 Set .ConsoleDialog = CreateScriptService(&quot;SFDialogs.Dialog&quot;, &quot;GlobalScope&quot;, &quot;ScriptForge&quot;, &quot;dlgConsole&quot;, _Context)
302 &apos; Setup labels and visibility
303 Set oModalBtn = .ConsoleDialog.Controls(&quot;CloseModalButton&quot;)
304 Set oNonModalBtn = .ConsoleDialog.Controls(&quot;CloseNonModalButton&quot;)
305 oModalBtn.Visible = Modal
306 oNonModalBtn.Visible = CBool(Not Modal)
307 &apos; Load console lines
308 _ConsoleRefresh()
309 .ConsoleDialog.Execute(Modal)
310 &apos; Terminate the modal dialog
311 If Modal Then
312 Set .ConsoleControl = .ConsoleControl.Dispose()
313 Set .ConsoleDialog = .ConsoleDialog.Dispose()
314 End If
315 End If
316 End With
318 Finally:
319 SF_Utils._ExitFunction(cstThisSub)
320 Exit Sub
321 End Sub &apos; ScriptForge.SF_Exception.Console
323 REM -----------------------------------------------------------------------------
324 Public Sub ConsoleClear(Optional ByVal Keep)
325 &apos;&apos;&apos; Clear the console keeping an optional number of recent messages
326 &apos;&apos;&apos; Args:
327 &apos;&apos;&apos; Keep: the number of messages to keep
328 &apos;&apos;&apos; If Keep is bigger than the number of messages stored in the console,
329 &apos;&apos;&apos; the console is not cleared
330 &apos;&apos;&apos; Example:
331 &apos;&apos;&apos; SF_Exception.ConsoleClear(5)
333 Dim lConsole As Long &apos; UBound of ConsoleLines
334 Const cstThisSub = &quot;Exception.ConsoleClear&quot;
335 Const cstSubArgs = &quot;[Keep=0]&quot;
337 If SF_Utils._ErrorHandling() Then On Local Error GoTo Finally &apos; Never interrupt processing
339 Check:
340 If IsMissing(Keep) Or IsEmpty(Keep) Then Keep = 0
341 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
342 If Not SF_Utils._Validate(Keep, &quot;Keep&quot;, V_NUMERIC) Then GoTo Finally
343 End If
345 Try:
346 With _SF_
347 If Keep &lt;= 0 Then
348 .ConsoleLines = Array()
349 Else
350 lConsole = UBound(.ConsoleLines)
351 If Keep &lt; lConsole + 1 Then .ConsoleLines = SF_Array.Slice(.ConsoleLines, lConsole - Keep + 1)
352 End If
353 End With
355 &apos; If active, the console dialog needs to be refreshed
356 _ConsoleRefresh()
358 Finally:
359 SF_Utils._ExitFunction(cstThisSub)
360 Exit Sub
361 End Sub &apos; ScriptForge.SF_Exception.ConsoleClear
363 REM -----------------------------------------------------------------------------
364 Public Function ConsoleToFile(Optional ByVal FileName As Variant) As Boolean
365 &apos;&apos;&apos; Export the content of the console to a text file
366 &apos;&apos;&apos; If the file exists and the console is not empty, it is overwritten without warning
367 &apos;&apos;&apos; Args:
368 &apos;&apos;&apos; FileName: the complete file name to export to. If it exists, is overwritten without warning
369 &apos;&apos;&apos; Returns:
370 &apos;&apos;&apos; True if the file could be created
371 &apos;&apos;&apos; Examples:
372 &apos;&apos;&apos; SF_Exception.ConsoleToFile(&quot;myFile.txt&quot;)
374 Dim bExport As Boolean &apos; Return value
375 Dim oFile As Object &apos; Output file handler
376 Dim sLine As String &apos; A single line
377 Const cstThisSub = &quot;Exception.ConsoleToFile&quot;
378 Const cstSubArgs = &quot;FileName&quot;
380 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
381 bExport = False
383 Check:
384 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
385 If Not SF_Utils._ValidateFile(FileName, &quot;FileName&quot;) Then GoTo Finally
386 End If
388 Try:
390 If UBound(_SF_.ConsoleLines) &gt; -1 Then
391 Set oFile = SF_FileSystem.CreateTextFile(FileName, Overwrite := True)
392 If Not IsNull(oFile) Then
393 With oFile
394 For Each sLine In _SF_.ConsoleLines
395 .WriteLine(sLine)
396 Next sLine
397 .CloseFile()
398 End With
399 End If
400 bExport = True
401 End If
403 Finally:
404 If Not IsNull(oFile) Then Set oFile = oFile.Dispose()
405 ConsoleToFile = bExport
406 SF_Utils._ExitFunction(cstThisSub)
407 Exit Function
408 Catch:
409 GoTo Finally
410 End Function &apos; ScriptForge.SF_Exception.ConsoleToFile
412 REM -----------------------------------------------------------------------------
413 Public Sub DebugDisplay(ParamArray pvArgs() As Variant)
414 &apos;&apos;&apos; Display the list of arguments in a readable form in a message box
415 &apos;&apos;&apos; Arguments are separated by a LINEFEED character
416 &apos;&apos;&apos; The maximum length of each individual argument = 1024 characters
417 &apos;&apos;&apos; Args:
418 &apos;&apos;&apos; Any number of arguments of any type
419 &apos;&apos;&apos; Examples:
420 &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))
422 Dim sOutputMsg As String &apos; Line to display
423 Dim sOutputCon As String &apos; Line to write in console
424 Dim sArgMsg As String &apos; Single argument
425 Dim sArgCon As String &apos; Single argument
426 Dim i As Integer
427 Const cstTab = 4
428 Const cstMaxLength = 1024
429 Const cstThisSub = &quot;Exception.DebugDisplay&quot;
430 Const cstSubArgs = &quot;Arg0, [Arg1, ...]&quot;
432 If SF_Utils._ErrorHandling() Then On Local Error Goto Finally &apos; Never interrupt processing
433 SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
434 Try:
435 &apos; Build new console line
436 sOutputMsg = &quot;&quot; : sOutputCon = &quot;&quot;
437 For i = 0 To UBound(pvArgs)
438 If IsError(pvArgs(i)) Then pvArgs(i) = &quot;&quot;
439 sArgMsg = Iif(i = 0, &quot;&quot;, SF_String.sfNEWLINE) &amp; SF_Utils._Repr(pvArgs(i), cstMaxLength) &apos;Do not use SF_String.Represent()
440 sArgCon = Iif(i = 0, &quot;&quot;, SF_String.sfTAB) &amp; SF_Utils._Repr(pvArgs(i), cstMaxLength)
441 sOutputMsg = sOutputMsg &amp; sArgMsg
442 sOutputCon = sOutputCon &amp; sArgCon
443 Next i
445 &apos; Add to actual console
446 _SF_._AddToConsole(SF_String.ExpandTabs(sOutputCon, cstTab))
447 &apos; Display the message
448 MsgBox(sOutputMsg, MB_OK + MB_ICONINFORMATION, &quot;DebugDisplay&quot;)
450 Finally:
451 SF_Utils._ExitFunction(cstThisSub)
452 Exit Sub
453 End Sub &apos; ScriptForge.SF_Exception.DebugDisplay
455 REM -----------------------------------------------------------------------------
456 Public Sub DebugPrint(ParamArray pvArgs() As Variant)
457 &apos;&apos;&apos; Print the list of arguments in a readable form in the console
458 &apos;&apos;&apos; Arguments are separated by a TAB character (simulated by spaces)
459 &apos;&apos;&apos; The maximum length of each individual argument = 1024 characters
460 &apos;&apos;&apos; Args:
461 &apos;&apos;&apos; Any number of arguments of any type
462 &apos;&apos;&apos; Examples:
463 &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))
465 Dim sOutput As String &apos; Line to write in console
466 Dim sArg As String &apos; Single argument
467 Dim i As Integer
468 Const cstTab = 4
469 Const cstMaxLength = 1024
470 Const cstThisSub = &quot;Exception.DebugPrint&quot;
471 Const cstSubArgs = &quot;Arg0, [Arg1, ...]&quot;
473 If SF_Utils._ErrorHandling() Then On Local Error Goto Finally &apos; Never interrupt processing
474 SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
475 Try:
476 &apos; Build new console line
477 sOutput = &quot;&quot;
478 For i = 0 To UBound(pvArgs)
479 If IsError(pvArgs(i)) Then pvArgs(i) = &quot;&quot;
480 sArg = Iif(i = 0, &quot;&quot;, SF_String.sfTAB) &amp; SF_Utils._Repr(pvArgs(i), cstMaxLength) &apos;Do not use SF_String.Represent()
481 sOutput = sOutput &amp; sArg
482 Next i
484 &apos; Add to actual console
485 _SF_._AddToConsole(SF_String.ExpandTabs(sOutput, cstTab))
487 Finally:
488 SF_Utils._ExitFunction(cstThisSub)
489 Exit Sub
490 End Sub &apos; ScriptForge.SF_Exception.DebugPrint
492 REM -----------------------------------------------------------------------------
493 Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
494 &apos;&apos;&apos; Return the actual value of the given property
495 &apos;&apos;&apos; Args:
496 &apos;&apos;&apos; PropertyName: the name of the property as a string
497 &apos;&apos;&apos; Returns:
498 &apos;&apos;&apos; The actual value of the property
499 &apos;&apos;&apos; If the property does not exist, returns Null
500 &apos;&apos;&apos; Exceptions
501 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
502 &apos;&apos;&apos; Examples:
503 &apos;&apos;&apos; myException.GetProperty(&quot;MyProperty&quot;)
505 Const cstThisSub = &quot;Exception.GetProperty&quot;
506 Const cstSubArgs = &quot;&quot;
508 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
509 GetProperty = Null
511 Check:
512 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
513 If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
514 End If
516 Try:
517 GetProperty = _PropertyGet(PropertyName)
519 Finally:
520 SF_Utils._ExitFunction(cstThisSub)
521 Exit Function
522 Catch:
523 GoTo Finally
524 End Function &apos; ScriptForge.SF_Exception.GetProperty
526 REM -----------------------------------------------------------------------------
527 Public Function Methods() As Variant
528 &apos;&apos;&apos; Return the list of public methods of the Exception service as an array
530 Methods = Array( _
531 &quot;Clear&quot; _
532 , &quot;Console&quot; _
533 , &quot;ConsoleClear&quot; _
534 , &quot;ConsoleToFile&quot; _
535 , &quot;DebugPrint&quot; _
536 , &quot;Raise&quot; _
537 , &quot;RaiseAbort&quot; _
538 , &quot;RaiseFatal&quot; _
539 , &quot;RaiseWarning&quot; _
542 End Function &apos; ScriptForge.SF_Exception.Methods
544 REM -----------------------------------------------------------------------------
545 Public Function Properties() As Variant
546 &apos;&apos;&apos; Return the list or properties of the Timer class as an array
548 Properties = Array( _
549 &quot;Description&quot; _
550 , &quot;Number&quot; _
551 , &quot;Source&quot; _
554 End Function &apos; ScriptForge.SF_Exception.Properties
556 REM -----------------------------------------------------------------------------
557 Public Sub PythonPrint(ParamArray pvArgs() As Variant)
558 &apos;&apos;&apos; Display the list of arguments in a readable form in the Python console
559 &apos;&apos;&apos; Arguments are separated by a TAB character (simulated by spaces)
560 &apos;&apos;&apos; The maximum length of each individual argument = 1024 characters
561 &apos;&apos;&apos; Args:
562 &apos;&apos;&apos; Any number of arguments of any type
563 &apos;&apos;&apos; Examples:
564 &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))
566 Dim sOutput As String &apos; Line to write in console
567 Dim sArg As String &apos; Single argument
568 Dim i As Integer
569 Const cstTab = 4
570 Const cstMaxLength = 1024
571 Const cstPyHelper = &quot;$&quot; &amp; &quot;_SF_Exception__PythonPrint&quot;
572 Const cstThisSub = &quot;Exception.PythonPrint&quot;
573 Const cstSubArgs = &quot;Arg0, [Arg1, ...]&quot;
575 If SF_Utils._ErrorHandling() Then On Local Error Goto Finally &apos; Never interrupt processing
576 SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
577 Try:
578 &apos; Build new console line
579 sOutput = &quot;&quot;
580 For i = 0 To UBound(pvArgs)
581 If IsError(pvArgs(i)) Then pvArgs(i) = &quot;&quot;
582 sArg = Iif(i = 0, &quot;&quot;, SF_String.sfTAB) &amp; SF_Utils._Repr(pvArgs(i), cstMaxLength)
583 sOutput = sOutput &amp; sArg
584 Next i
586 &apos; Add to actual console
587 sOutput = SF_String.ExpandTabs(sOutput, cstTab)
588 _SF_._AddToConsole(sOutput)
589 &apos; Display the message in the Python shell console
590 With ScriptForge.SF_Session
591 .ExecutePythonScript(.SCRIPTISSHARED, _SF_.PythonHelper &amp; cstPyHelper, sOutput)
592 End With
594 Finally:
595 SF_Utils._ExitFunction(cstThisSub)
596 Exit Sub
597 End Sub &apos; ScriptForge.SF_Exception.PythonPrint
599 REM -----------------------------------------------------------------------------
600 Public Sub Raise(Optional ByVal Number As Variant _
601 , Optional ByVal Source As Variant _
602 , Optional ByVal Description As Variant _
604 &apos;&apos;&apos; Generate a run-time error. An error message is displayed to the user and logged
605 &apos;&apos;&apos; in the console. The execution is STOPPED
606 &apos;&apos;&apos; Args:
607 &apos;&apos;&apos; Number: the error number, may be numeric or string
608 &apos;&apos;&apos; If numeric and &lt;= 2000, it is considered a LibreOffice Basic run-time error (default = Err)
609 &apos;&apos;&apos; Source: the line where the error occurred (default = Erl) or any string describing the location of the error
610 &apos;&apos;&apos; Description: the error message to log in the console and to display to the user
611 &apos;&apos;&apos; Examples:
612 &apos;&apos;&apos; On Local Error GoTo Catch
613 &apos;&apos;&apos; &apos; ...
614 &apos;&apos;&apos; Catch:
615 &apos;&apos;&apos; SF_Exception.Raise() &apos; Standard behaviour
616 &apos;&apos;&apos; SF_Exception.Raise(11) &apos; Force division by zero
617 &apos;&apos;&apos; SF_Exception.Raise(&quot;MYAPPERROR&quot;, &quot;myFunction&quot;, &quot;Application error&quot;)
618 &apos;&apos;&apos; SF_Exception.Raise(,, &quot;To divide by zero is not a good idea !&quot;)
620 Dim sMessage As String &apos; Error message to log and to display
621 Dim L10N As Object &apos; Alias to LocalizedInterface
622 Const cstThisSub = &quot;Exception.Raise&quot;
623 Const cstSubArgs = &quot;[Number=Err], [Source=Erl], [Description]&quot;
625 &apos; Save Err, Erl, .. values before any On Error ... statement
626 SF_Exception._CaptureSystemError()
627 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
629 Check:
630 If IsMissing(Number) Or IsEmpty(Number) Then Number = -1
631 If IsMissing(Source) Or IsEmpty(Source) Then Source = -1
632 If IsMissing(Description) Or IsEmpty(Description) Then Description = &quot;&quot;
633 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
634 If Not SF_Utils._Validate(Number, &quot;Number&quot;, Array(V_STRING, V_NUMERIC)) Then GoTo Finally
635 If Not SF_Utils._Validate(Source, &quot;Source&quot;, Array(V_STRING, V_NUMERIC)) Then GoTo Finally
636 If Not SF_Utils._Validate(Description, &quot;Description&quot;, V_STRING) Then GoTo Finally
637 End If
639 Try:
640 With SF_Exception
641 If Number &gt;= 0 Then .Number = Number
642 If VarType(Source) = V_STRING Then
643 If Len(Source) &gt; 0 Then .Source = Source
644 ElseIf Source &gt;= 0 Then &apos; -1 = Default =&gt; no change
645 .Source = Source
646 End If
647 If Len(Description) &gt; 0 Then .Description = Description
649 &apos; Log and display
650 Set L10N = _SF_._GetLocalizedInterface()
651 sMessage = L10N.GetText(&quot;LONGERRORDESC&quot;, .Number, .Source, .Description)
652 .DebugPrint(sMessage)
653 If _SF_.DisplayEnabled Then MsgBox L10N.GetText(&quot;ERRORNUMBER&quot;, .Number) _
654 &amp; SF_String.sfNewLine &amp; L10N.GetText(&quot;ERRORLOCATION&quot;, .Source) _
655 &amp; SF_String.sfNewLine &amp; .Description _
656 , MB_OK + MB_ICONSTOP _
657 , L10N.GetText(&quot;ERRORNUMBER&quot;, .Number)
658 .Clear()
659 End With
661 Finally:
662 SF_Utils._ExitFunction(cstThisSub)
663 If _SF_.StopWhenError Then
664 _SF_._StackReset()
665 Stop
666 End If
667 Exit Sub
668 Catch:
669 GoTo Finally
670 End Sub &apos; ScriptForge.SF_Exception.Raise
672 REM -----------------------------------------------------------------------------
673 Public Sub RaiseAbort(Optional ByVal Source As Variant)
674 &apos;&apos;&apos; Manage a run-time error that occurred inside the ScriptForge piece of software itself.
675 &apos;&apos;&apos; The event is logged.
676 &apos;&apos;&apos; The execution is STOPPED
677 &apos;&apos;&apos; For INTERNAL USE only
678 &apos;&apos;&apos; Args:
679 &apos;&apos;&apos; Source: the line where the error occurred
681 Dim sLocation As String &apos; Common header in error messages: location of error
682 Dim vLocation As Variant &apos; Split array (library, module, method)
683 Dim sMessage As String &apos; Error message to log and to display
684 Dim L10N As Object &apos; Alias to LocalizedInterface
685 Const cstTabSize = 4
686 Const cstThisSub = &quot;Exception.RaiseAbort&quot;
687 Const cstSubArgs = &quot;[Source=Erl]&quot;
689 &apos; Save Err, Erl, .. values before any On Error ... statement
690 SF_Exception._CaptureSystemError()
691 On Local Error Resume Next
693 Check:
694 If IsMissing(Source) Or IsEmpty(Source) Then Source = &quot;&quot;
696 Try:
697 With SF_Exception
699 &apos; Prepare message header
700 Set L10N = _SF_._GetLocalizedInterface()
701 If Len(_SF_.MainFunction) &gt; 0 Then &apos; MainFunction = [Library.]Module.Method
702 vLocation = Split(_SF_.MainFunction, &quot;.&quot;)
703 If UBound(vLocation) &lt; 2 Then vLocation = SF_Array.Prepend(vLocation, &quot;ScriptForge&quot;)
704 sLocation = L10N.GetText(&quot;VALIDATESOURCE&quot;, vLocation(0), vLocation(1), vLocation(2)) &amp; &quot;\n\n\n&quot;
705 Else
706 sLocation = &quot;&quot;
707 End If
709 &apos; Log and display
710 sMessage = L10N.GetText(&quot;LONGERRORDESC&quot;, .Number, .Source, .Description)
711 .DebugPrint(sMessage)
712 If _SF_.DisplayEnabled Then
713 sMessage = sLocation _
714 &amp; L10N.GetText(&quot;INTERNALERROR&quot;) _
715 &amp; L10N.GetText(&quot;ERRORLOCATION&quot;, Source &amp; &quot;/&quot; &amp; .Source) &amp; SF_String.sfNewLine &amp; .Description _
716 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; L10N.GetText(&quot;STOPEXECUTION&quot;)
717 MsgBox SF_String.ExpandTabs(SF_String.Unescape(sMessage), cstTabSize) _
718 , MB_OK + MB_ICONSTOP _
719 , L10N.GetText(&quot;ERRORNUMBER&quot;, .Number)
720 End If
722 .Clear()
723 End With
725 Finally:
726 _SF_._StackReset()
727 If _SF_.StopWhenError Then Stop
728 Exit Sub
729 Catch:
730 GoTo Finally
731 End Sub &apos; ScriptForge.SF_Exception.RaiseAbort
733 REM -----------------------------------------------------------------------------
734 Public Sub RaiseFatal(Optional ByVal ErrorCode As Variant _
735 , ParamArray pvArgs _
737 &apos;&apos;&apos; Generate a run-time error caused by an anomaly in a user script detected by ScriptForge
738 &apos;&apos;&apos; The message is logged in the console. The execution is STOPPED
739 &apos;&apos;&apos; For INTERNAL USE only
740 &apos;&apos;&apos; Args:
741 &apos;&apos;&apos; ErrorCode: as a string, the unique identifier of the error
742 &apos;&apos;&apos; pvArgs: the arguments to insert in the error message
744 Dim sLocation As String &apos; Common header in error messages: location of error
745 Dim sService As String &apos; Service name having detected the error
746 Dim sMethod As String &apos; Method name having detected the error
747 Dim vLocation As Variant &apos; Split array (library, module, method)
748 Dim sMessage As String &apos; Message to log and display
749 Dim L10N As Object &apos; Alias of LocalizedInterface
750 Dim sAlt As String &apos; Alternative error messages
751 Dim iButtons As Integer &apos; MB_OK or MB_YESNO
752 Dim iMsgBox As Integer &apos; Return value of the message box
754 Const cstTabSize = 4
755 Const cstThisSub = &quot;Exception.RaiseFatal&quot;
756 Const cstSubArgs = &quot;ErrorCode, [Arg0[, Arg1 ...]]&quot;
757 Const cstStop = &quot;&quot; &apos; Chr(9211)
759 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
761 Check:
762 If IsMissing(ErrorCode) Or IsEmpty(ErrorCode) Then ErrorCode = &quot;&quot;
763 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
764 If Not SF_Utils._Validate(ErrorCode, &quot;ErrorCode&quot;, V_STRING) Then GoTo Finally
765 End If
767 Try:
768 Set L10N = _SF_._GetLocalizedInterface()
769 &apos; Location header common to all error messages
770 If Len(_SF_.MainFunction) &gt; 0 Then &apos; MainFunction = [Library.]Module.Method
771 vLocation = Split(_SF_.MainFunction, &quot;.&quot;)
772 If UBound(vLocation) &lt; 2 Then vLocation = SF_Array.Prepend(vLocation, &quot;ScriptForge&quot;)
773 sService = vLocation(1)
774 sMethod = vLocation(2)
775 sLocation = L10N.GetText(&quot;VALIDATESOURCE&quot;, vLocation(0), sService, sMethod) _
776 &amp; &quot;\n&quot; &amp; L10N.GetText(&quot;VALIDATEARGS&quot;, _RightCaseArgs(_SF_.MainFunctionArgs))
777 Else
778 sService = &quot;&quot;
779 sMethod = &quot;&quot;
780 sLocation = &quot;&quot;
781 End If
783 With L10N
784 Select Case UCase(ErrorCode)
785 Case MISSINGARGERROR &apos; SF_Utils._Validate(Name)
786 pvArgs(0) = _RightCase(pvArgs(0))
787 sMessage = sLocation _
788 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
789 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEMISSING&quot;, pvArgs(0))
790 Case ARGUMENTERROR &apos; SF_Utils._Validate(Value, Name, Types, Values, Regex, Class)
791 pvArgs(1) = _RightCase(pvArgs(1))
792 sMessage = sLocation _
793 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(1)) _
794 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATIONRULES&quot;)
795 If Len(pvArgs(2)) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATETYPES&quot;, pvArgs(1), pvArgs(2))
796 If Len(pvArgs(3)) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEVALUES&quot;, pvArgs(1), pvArgs(3))
797 If Len(pvArgs(4)) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEREGEX&quot;, pvArgs(1), pvArgs(4))
798 If Len(pvArgs(5)) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATECLASS&quot;, pvArgs(1), pvArgs(5))
799 sMessage = sMessage &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEACTUAL&quot;, pvArgs(1), pvArgs(0))
800 Case ARRAYERROR &apos; SF_Utils._ValidateArray(Value, Name, Dimensions, Types, NotNull)
801 pvArgs(1) = _RightCase(pvArgs(1))
802 sMessage = sLocation _
803 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(1)) _
804 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATIONRULES&quot;) _
805 &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEARRAY&quot;, pvArgs(1))
806 If pvArgs(2) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEDIMS&quot;, pvArgs(1), pvArgs(2))
807 If Len(pvArgs(3)) &gt; 0 Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEALLTYPES&quot;, pvArgs(1), pvArgs(3))
808 If pvArgs(4) Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATENOTNULL&quot;, pvArgs(1))
809 sMessage = sMessage &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEACTUAL&quot;, pvArgs(1), pvArgs(0))
810 Case FILEERROR &apos; SF_Utils._ValidateFile(Value, Name, WildCards)
811 pvArgs(1) = _RightCase(pvArgs(1))
812 sMessage = sLocation _
813 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(1)) _
814 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATIONRULES&quot;) _
815 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEFILE&quot;, pvArgs(1))
816 sAlt = &quot;VALIDATEFILE&quot; &amp; SF_FileSystem.FileNaming
817 sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(sAlt, pvArgs(1))
818 If pvArgs(2) Then sMessage = sMessage &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEWILDCARD&quot;, pvArgs(1))
819 sMessage = sMessage &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEACTUAL&quot;, pvArgs(1), pvArgs(0))
820 Case ARRAYSEQUENCEERROR &apos; SF_Array.RangeInit(From, UpTo, ByStep)
821 sMessage = sLocation _
822 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;ARRAYSEQUENCE&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
823 Case ARRAYINSERTERROR &apos; SF_Array.AppendColumn/Row/PrependColumn/Row(VectorName, Array_2D, Vector)
824 sMessage = sLocation _
825 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;ARRAYINSERT&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
826 Case ARRAYINDEX1ERROR &apos; SF_Array.ExtractColumn/Row(IndexName, Array_2D, Index)
827 sMessage = sLocation _
828 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;ARRAYINDEX1&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
829 Case ARRAYINDEX2ERROR &apos; SF_Array.Slice(From, UpTo)
830 sMessage = sLocation _
831 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;ARRAYINDEX2&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
832 Case CSVPARSINGERROR &apos; SF_Array.ImportFromCSVFile(FileName, LineNumber, Line)
833 sMessage = sLocation _
834 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CSVPARSING&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
835 Case DUPLICATEKEYERROR &apos; SF_Dictionary.Add/ReplaceKey(&quot;Key&quot;, Key)
836 sMessage = sLocation _
837 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
838 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DUPLICATEKEY&quot;, pvArgs(0), pvArgs(1))
839 Case UNKNOWNKEYERROR &apos; SF_Dictionary.Remove/ReplaceItem/ReplaceKey(&quot;Key&quot;, Key)
840 sMessage = sLocation _
841 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
842 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNKNOWNKEY&quot;, pvArgs(0), pvArgs(1))
843 Case INVALIDKEYERROR &apos; SF_Dictionary.Add/ReplaceKey(Key)
844 sMessage = sLocation _
845 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
846 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;INVALIDKEY&quot;)
847 Case UNKNOWNFILEERROR &apos; SF_FileSystem.CopyFile/MoveFile/DeleteFile/CreateScriptService(&quot;L10N&quot;)(ArgName, Filename)
848 pvArgs(0) = _RightCase(pvArgs(0))
849 sMessage = sLocation _
850 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
851 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNKNOWNFILE&quot;, pvArgs(0), pvArgs(1))
852 Case UNKNOWNFOLDERERROR &apos; SF_FileSystem.CopyFolder/MoveFolder/DeleteFolder/Files/SubFolders(ArgName, Filename)
853 pvArgs(0) = _RightCase(pvArgs(0))
854 sMessage = sLocation _
855 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
856 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNKNOWNFOLDER&quot;, pvArgs(0), pvArgs(1))
857 Case NOTAFILEERROR &apos; SF_FileSystem.CopyFile/MoveFile/DeleteFile(ArgName, Filename)
858 pvArgs(0) = _RightCase(pvArgs(0))
859 sMessage = sLocation _
860 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
861 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;NOTAFILE&quot;, pvArgs(0), pvArgs(1))
862 Case NOTAFOLDERERROR &apos; SF_FileSystem.CopyFolder/MoveFolder/DeleteFolder/Files/SubFolders(ArgName, Filename)
863 pvArgs(0) = _RightCase(pvArgs(0))
864 sMessage = sLocation _
865 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
866 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;NOTAFOLDER&quot;, pvArgs(0), pvArgs(1))
867 Case OVERWRITEERROR &apos; SF_FileSystem.Copy+Move/File+Folder/CreateTextFile/OpenTextFile(ArgName, Filename)
868 pvArgs(0) = _RightCase(pvArgs(0))
869 sMessage = sLocation _
870 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
871 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;OVERWRITE&quot;, pvArgs(0), pvArgs(1))
872 Case READONLYERROR &apos; SF_FileSystem.Copy+Move+Delete/File+Folder(ArgName, Filename)
873 pvArgs(0) = _RightCase(pvArgs(0))
874 sMessage = sLocation _
875 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
876 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;READONLY&quot;, pvArgs(0), pvArgs(1))
877 Case NOFILEMATCHERROR &apos; SF_FileSystem.Copy+Move+Delete/File+Folder(ArgName, Filename)
878 pvArgs(0) = _RightCase(pvArgs(0))
879 sMessage = sLocation _
880 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
881 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;NOFILEMATCH&quot;, pvArgs(0), pvArgs(1))
882 Case FOLDERCREATIONERROR &apos; SF_FileSystem.CreateFolder(ArgName, Filename)
883 pvArgs(0) = _RightCase(pvArgs(0))
884 sMessage = sLocation _
885 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
886 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FOLDERCREATION&quot;, pvArgs(0), pvArgs(1))
887 Case UNKNOWNSERVICEERROR &apos; SF_Services.CreateScriptService(ArgName, Value, Library, Service)
888 pvArgs(0) = _RightCase(pvArgs(0))
889 sMessage = sLocation _
890 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
891 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNKNOWNSERVICE&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
892 Case SERVICESNOTLOADEDERROR &apos; SF_Services.CreateScriptService(ArgName, Value, Library)
893 pvArgs(0) = _RightCase(pvArgs(0))
894 sMessage = sLocation _
895 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
896 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SERVICESNOTLOADED&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
897 Case CALCFUNCERROR &apos; SF_Session.ExecuteCalcFunction(CalcFunction)
898 sMessage = sLocation _
899 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, _RightCase(&quot;CalcFunction&quot;)) _
900 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CALCFUNC&quot;, pvArgs(0))
901 Case NOSCRIPTERROR &apos; SF_Session._GetScript(Language, &quot;Scope&quot;, Scope, &quot;Script&quot;, Script)
902 pvArgs(1) = _RightCase(pvArgs(1)) : pvArgs(3) = _RightCase(pvArgs(3))
903 sMessage = sLocation _
904 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, _RightCase(&quot;Script&quot;)) _
905 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;NOSCRIPT&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4))
906 Case SCRIPTEXECERROR &apos; SF_Session.ExecuteBasicScript(&quot;Script&quot;, Script, Cause)
907 pvArgs(0) = _RightCase(pvArgs(0))
908 sMessage = sLocation _
909 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SCRIPTEXEC&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
910 Case WRONGEMAILERROR &apos; SF_Session.SendMail(Arg, Email)
911 pvArgs(0) = _RightCase(pvArgs(0))
912 sMessage = sLocation _
913 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
914 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;WRONGEMAIL&quot;, pvArgs(1))
915 Case SENDMAILERROR &apos; SF_Session.SendMail()
916 sMessage = sLocation _
917 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SENDMAIL&quot;)
918 Case FILENOTOPENERROR &apos; SF_TextStream._IsFileOpen(FileName)
919 sMessage = sLocation _
920 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FILENOTOPEN&quot;, pvArgs(0))
921 Case FILEOPENMODEERROR &apos; SF_TextStream._IsFileOpen(FileName)
922 sMessage = sLocation _
923 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FILEOPENMODE&quot;, pvArgs(0), pvArgs(1))
924 Case ENDOFFILEERROR &apos; SF_TextStream.ReadLine/ReadAll/SkipLine(FileName)
925 sMessage = sLocation _
926 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;ENDOFFILE&quot;, pvArgs(0))
927 Case DOCUMENTERROR &apos; SF_UI.GetDocument(ArgName, WindowName)
928 pvArgs(0) = _RightCase(pvArgs(0))
929 sMessage = sLocation _
930 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
931 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENT&quot;, pvArgs(0), pvArgs(1))
932 Case DOCUMENTCREATIONERROR &apos; SF_UI.Create(Arg1Name, DocumentType, Arg2Name, TemplateFile)
933 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
934 sMessage = sLocation _
935 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENTCREATION&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
936 Case DOCUMENTOPENERROR &apos; SF_UI.OpenDocument(Arg1Name, FileName, Arg2Name, Password, Arg3Name, FilterName)
937 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2)) : pvArgs(4) = _RightCase(pvArgs(4))
938 sMessage = sLocation _
939 &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))
940 Case BASEDOCUMENTOPENERROR &apos; SF_UI.OpenBaseDocument(Arg1Name, FileName, Arg2Name, RegistrationName)
941 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
942 sMessage = sLocation _
943 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;BASEDOCUMENTOPEN&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
944 Case DOCUMENTDEADERROR &apos; SF_Document._IsStillAlive(FileName)
945 sMessage = sLocation _
946 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENTDEAD&quot;, pvArgs(0))
947 Case DOCUMENTSAVEERROR &apos; SF_Document.Save(Arg1Name, FileName)
948 pvArgs(0) = _RightCase(pvArgs(0))
949 sMessage = sLocation _
950 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENTSAVE&quot;, pvArgs(0), pvArgs(1))
951 Case DOCUMENTSAVEASERROR &apos; SF_Document.SaveAs(Arg1Name, FileName, Arg2, Overwrite, Arg3, FilterName)
952 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2)) : pvArgs(4) = _RightCase(pvArgs(4))
953 sMessage = sLocation _
954 &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))
955 Case DOCUMENTREADONLYERROR &apos; SF_Document.update property(&quot;Document&quot;, FileName)
956 pvArgs(0) = _RightCase(pvArgs(0))
957 sMessage = sLocation _
958 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DOCUMENTREADONLY&quot;, pvArgs(0), pvArgs(1))
959 Case DBCONNECTERROR &apos; SF_Base.GetDatabase(&quot;User&quot;, User, &quot;Password&quot;, Password, FileName)
960 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
961 sMessage = sLocation _
962 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DBCONNECT&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4))
963 Case CALCADDRESSERROR &apos; SF_Calc._ParseAddress(Address, &quot;Range&quot;/&quot;Sheet&quot;, Scope, Document)
964 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
965 sMessage = sLocation _
966 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
967 &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))
968 Case DUPLICATESHEETERROR &apos; SF_Calc.InsertSheet(arg, SheetName, Document)
969 pvArgs(0) = _RightCase(pvArgs(0))
970 sMessage = sLocation _
971 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
972 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DUPLICATESHEET&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
973 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)
974 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2)) : pvArgs(4) = _RightCase(pvArgs(4))
975 pvArgs(6) = _RightCase(pvArgs(6)) : pvArgs(8) = _RightCase(pvArgs(8)) : pvArgs(10) = _RightCase(pvArgs(10))
976 sMessage = sLocation _
977 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;OFFSETADDRESS&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4) _
978 , pvArgs(5), pvArgs(6), pvArgs(7), pvArgs(8), pvArgs(9), pvArgs(10), pvArgs(11))
979 Case DUPLICATECHARTERROR &apos; SF_Calc.CreateChart(chart, ChartName, sheet, SheetName, Document, file)
980 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
981 sMessage = sLocation _
982 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
983 &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))
984 Case RANGEEXPORTERROR &apos; SF_Calc.ExportRangeToFile(Arg1Name, FileName, Arg2, Overwrite)
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;RANGEEXPORT&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
988 Case CHARTEXPORTERROR &apos; SF_Chart.ExportToFile(Arg1Name, FileName, Arg2, Overwrite)
989 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2))
990 sMessage = sLocation _
991 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CHARTEXPORT&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
992 Case FORMDEADERROR &apos; SF_Form._IsStillAlive(FormName, DocumentName)
993 sMessage = sLocation _
994 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FORMDEAD&quot;, pvArgs(0), pvArgs(1))
995 Case CALCFORMNOTFOUNDERROR &apos; SF_Calc.Forms(Index, SheetName, Document)
996 sMessage = sLocation _
997 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CALCFORMNOTFOUND&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
998 Case WRITERFORMNOTFOUNDERROR &apos; SF_Document.Forms(Index, Document)
999 sMessage = sLocation _
1000 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;WRITERFORMNOTFOUND&quot;, pvArgs(0), pvArgs(1))
1001 Case BASEFORMNOTFOUNDERROR &apos; SF_Base.Forms(Index, FormDocument, BaseDocument)
1002 sMessage = sLocation _
1003 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;BASEFORMNOTFOUND&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
1004 Case SUBFORMNOTFOUNDERROR &apos; SF_Form.Subforms(Subform, Mainform)
1005 sMessage = sLocation _
1006 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SUBFORMNOTFOUND&quot;, pvArgs(0), pvArgs(1))
1007 Case FORMCONTROLTYPEERROR &apos; SF_FormControl._SetProperty(ControlName, FormName, ControlType, Property)
1008 sMessage = sLocation _
1009 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;FORMCONTROLTYPE&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
1010 Case DIALOGNOTFOUNDERROR &apos; SF_Dialog._NewDialog(Service, DialogName, WindowName)
1011 pvArgs(0) = _RightCase(pvArgs(0)) : pvArgs(2) = _RightCase(pvArgs(2)) : pvArgs(4) = _RightCase(pvArgs(4))
1012 pvArgs(6) = _RightCase(pvArgs(6))
1013 sMessage = sLocation _
1014 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DIALOGNOTFOUND&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3), pvArgs(4) _
1015 , pvArgs(5), pvArgs(6), pvArgs(7))
1016 Case DIALOGDEADERROR &apos; SF_Dialog._IsStillAlive(DialogName)
1017 sMessage = sLocation _
1018 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DIALOGDEAD&quot;, pvArgs(0))
1019 Case CONTROLTYPEERROR &apos; SF_DialogControl._SetProperty(ControlName, DialogName, ControlType, Property)
1020 sMessage = sLocation _
1021 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;CONTROLTYPE&quot;, pvArgs(0), pvArgs(1), pvArgs(2), pvArgs(3))
1022 Case TEXTFIELDERROR &apos; SF_DialogControl.WriteLine(ControlName, DialogName)
1023 sMessage = sLocation _
1024 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;TEXTFIELD&quot;, pvArgs(0), pvArgs(1))
1025 Case PAGEMANAGERERROR &apos; SF_Dialog.SetPageManager(PilotsList, TabsList, WizardsList)
1026 sMessage = sLocation _
1027 &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))
1028 Case DUPLICATECONTROLERROR &apos; SF_Dialog.CreateControl(ControlName, DialogName)
1029 pvArgs(0) = _RightCase(pvArgs(0))
1030 sMessage = sLocation _
1031 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, pvArgs(0)) _
1032 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DUPLICATECONTROL&quot;, pvArgs(0), pvArgs(1), pvArgs(2))
1033 Case DBREADONLYERROR &apos; SF_Database.RunSql()
1034 sMessage = sLocation _
1035 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;DBREADONLY&quot;, vLocation(2))
1036 Case SQLSYNTAXERROR &apos; SF_Database._ExecuteSql(SQL)
1037 sMessage = sLocation _
1038 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;SQLSYNTAX&quot;, pvArgs(0))
1039 Case PYTHONSHELLERROR &apos; SF_Exception.PythonShell (Python only)
1040 sMessage = sLocation _
1041 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;PYTHONSHELL&quot;)
1042 Case UNITTESTLIBRARYERROR &apos; SFUnitTests._NewUnitTest(LibraryName)
1043 sMessage = sLocation _
1044 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNITTESTLIBRARY&quot;, pvArgs(0))
1045 Case UNITTESTMETHODERROR &apos; SFUnitTests.SF_UnitTest(Method)
1046 sMessage = sLocation _
1047 &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;UNITTESTMETHOD&quot;, pvArgs(0))
1048 Case Else
1049 End Select
1050 End With
1052 &apos; Log fatal event
1053 _SF_._AddToConsole(sMessage)
1055 &apos; Display fatal event, if relevant (default)
1056 If _SF_.DisplayEnabled Then
1057 If _SF_.StopWhenError Then sMessage = sMessage &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; L10N.GetText(&quot;STOPEXECUTION&quot;)
1058 &apos; Do you need more help ?
1059 If Len(sMethod) &gt; 0 Then
1060 sMessage = sMessage &amp; &quot;\n&quot; &amp; &quot;\n&quot; &amp; L10N.GetText(&quot;NEEDMOREHELP&quot;, sMethod)
1061 iButtons = MB_YESNO + MB_DEFBUTTON2
1062 Else
1063 iButtons = MB_OK
1064 End If
1065 iMsgBox = MsgBox(SF_String.ExpandTabs(SF_String.Unescape(sMessage), cstTabSize) _
1066 , iButtons + MB_ICONEXCLAMATION _
1067 , L10N.GetText(&quot;ERRORNUMBER&quot;, ErrorCode) _
1069 &apos; If more help needed ...
1070 If iMsgBox = IDYES Then _OpenHelpInBrowser(sService, sMethod)
1071 End If
1073 Finally:
1074 SF_Utils._ExitFunction(cstThisSub)
1075 _SF_._StackReset()
1076 If _SF_.StopWhenError Then Stop
1077 Exit Sub
1078 Catch:
1079 GoTo Finally
1080 End Sub &apos; ScriptForge.SF_Exception.RaiseFatal
1082 REM -----------------------------------------------------------------------------
1083 Public Sub RaiseWarning(Optional ByVal Number As Variant _
1084 , Optional ByVal Source As Variant _
1085 , Optional ByVal Description As Variant _
1087 &apos;&apos;&apos; Generate a run-time error. An error message is displayed to the user and logged
1088 &apos;&apos;&apos; in the console. The execution is NOT STOPPED
1089 &apos;&apos;&apos; Args:
1090 &apos;&apos;&apos; Number: the error number, may be numeric or string
1091 &apos;&apos;&apos; If numeric and &lt;= 2000, it is considered a LibreOffice Basic run-time error (default = Err)
1092 &apos;&apos;&apos; Source: the line where the error occurred (default = Erl) or any string describing the location of the error
1093 &apos;&apos;&apos; Description: the error message to log in the console and to display to the user
1094 &apos;&apos;&apos; Returns:
1095 &apos;&apos;&apos; True if successful. Anyway, the execution continues
1096 &apos;&apos;&apos; Examples:
1097 &apos;&apos;&apos; On Local Error GoTo Catch
1098 &apos;&apos;&apos; &apos; ...
1099 &apos;&apos;&apos; Catch:
1100 &apos;&apos;&apos; SF_Exception.RaiseWarning() &apos; Standard behaviour
1101 &apos;&apos;&apos; SF_Exception.RaiseWarning(11) &apos; Force division by zero
1102 &apos;&apos;&apos; SF_Exception.RaiseWarning(&quot;MYAPPERROR&quot;, &quot;myFunction&quot;, &quot;Application error&quot;)
1103 &apos;&apos;&apos; SF_Exception.RaiseWarning(,, &quot;To divide by zero is not a good idea !&quot;)
1105 Dim bStop As Boolean &apos; Alias for stop switch
1106 Const cstThisSub = &quot;Exception.RaiseWarning&quot;
1107 Const cstSubArgs = &quot;[Number=Err], [Source=Erl], [Description]&quot;
1109 &apos; Save Err, Erl, .. values before any On Error ... statement
1110 SF_Exception._CaptureSystemError()
1111 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1113 Check:
1114 If IsMissing(Number) Or IsEmpty(Number) Then Number = -1
1115 If IsMissing(Source) Or IsEmpty(Source) Then Source = -1
1116 If IsMissing(Description) Or IsEmpty(Description) Then Description = &quot;&quot;
1117 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1118 If Not SF_Utils._Validate(Number, &quot;Number&quot;, Array(V_STRING, V_NUMERIC, V_EMPTY)) Then GoTo Finally
1119 If Not SF_Utils._Validate(Source, &quot;Source&quot;, Array(V_STRING, V_NUMERIC, V_EMPTY)) Then GoTo Finally
1120 If Not SF_Utils._Validate(Description, &quot;Description&quot;, V_STRING) Then GoTo Finally
1121 End If
1123 Try:
1124 bStop = _SF_.StopWhenError &apos; Store current value to reset it before leaving the Sub
1125 _SF_.StopWhenError = False
1126 SF_Exception.Raise(Number, Source, Description)
1128 Finally:
1129 SF_Utils._ExitFunction(cstThisSub)
1130 _SF_.StopWhenError = bStop
1131 Exit Sub
1132 Catch:
1133 GoTo Finally
1134 End Sub &apos; ScriptForge.SF_Exception.RaiseWarning
1136 REM -----------------------------------------------------------------------------
1137 Public Function SetProperty(Optional ByVal PropertyName As Variant _
1138 , Optional ByRef Value As Variant _
1139 ) As Boolean
1140 &apos;&apos;&apos; Set a new value to the given property
1141 &apos;&apos;&apos; Args:
1142 &apos;&apos;&apos; PropertyName: the name of the property as a string
1143 &apos;&apos;&apos; Value: its new value
1144 &apos;&apos;&apos; Exceptions
1145 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
1147 Const cstThisSub = &quot;Exception.SetProperty&quot;
1148 Const cstSubArgs = &quot;PropertyName, Value&quot;
1150 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1151 SetProperty = False
1153 Check:
1154 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1155 If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
1156 End If
1158 Try:
1159 SetProperty = _PropertySet(PropertyName, Value)
1161 Finally:
1162 SF_Utils._ExitFunction(cstThisSub)
1163 Exit Function
1164 Catch:
1165 GoTo Finally
1166 End Function &apos; ScriptForge.SF_Exception.SetProperty
1168 REM =========================================================== PRIVATE FUNCTIONS
1170 REM -----------------------------------------------------------------------------
1171 Private Sub _CaptureSystemError()
1172 &apos;&apos;&apos; Store system error status in system error properties
1173 &apos;&apos;&apos; Called at each invocation of an error management property or method
1174 &apos;&apos;&apos; Reset by SF_Exception.Clear()
1176 If Err &gt; 0 And _SysNumber = 0 Then
1177 _SysNumber = Err
1178 _SysSource = Erl
1179 _SysDescription = Error$
1180 End If
1182 End Sub &apos; ScriptForge.SF_Exception._CaptureSystemError
1184 REM -----------------------------------------------------------------------------
1185 Public Sub _CloseConsole(Optional ByRef poEvent As Object)
1186 &apos;&apos;&apos; Close the console when opened in non-modal mode
1187 &apos;&apos;&apos; Triggered by the CloseNonModalButton from the dlgConsole dialog
1189 On Local Error GoTo Finally
1191 Try:
1192 With _SF_
1193 If Not IsNull(.ConsoleDialog) Then
1194 If .ConsoleDialog._IsStillAlive(False) Then &apos; False to not raise an error
1195 Set .ConsoleControl = .ConsoleControl.Dispose()
1196 Set .ConsoleDialog = .ConsoleDialog.Dispose()
1197 End If
1198 End If
1199 End With
1201 Finally:
1202 Exit Sub
1203 End Sub &apos; ScriptForge.SF_Exception._CloseConsole
1205 REM -----------------------------------------------------------------------------
1206 Private Sub _ConsoleRefresh()
1207 &apos;&apos;&apos; Reload the content of the console in the dialog
1208 &apos;&apos;&apos; Needed when console first loaded or when totally or partially cleared
1210 With _SF_
1211 &apos; Do nothing if console inactive
1212 If IsNull(.ConsoleDialog) Then GoTo Finally
1213 If Not .ConsoleDialog._IsStillAlive(False) Then &apos; False to not generate an error when dead
1214 Set .ConsoleControl = .ConsoleControl.Dispose()
1215 Set .ConsoleDialog = Nothing
1216 GoTo Finally
1217 End If
1218 &apos; Store the relevant text in the control
1219 If IsNull(.ConsoleControl) Then Set .ConsoleControl = .ConsoleDialog.Controls(CONSOLENAME)
1220 .ConsoleControl.Value = &quot;&quot;
1221 If UBound(.ConsoleLines) &gt;= 0 Then .ConsoleControl.WriteLine(Join(.ConsoleLines, SF_String.sfNEWLINE))
1222 End With
1224 Finally:
1225 Exit Sub
1226 End Sub &apos; ScriptForge.SF_Exception._ConsoleRefresh
1228 REM -----------------------------------------------------------------------------
1229 Private Sub _OpenHelpInBrowser(ByVal psService As String, ByVal psMethod As String)
1230 &apos;&apos;&apos; Open the help page and help anchor related to the given ScriptForge service and method
1232 Dim sUrl As String &apos; URL to open
1233 Const cstURL = &quot;https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_%1.html?&amp;DbPAR=BASIC#%2&quot;
1235 On Local Error GoTo Finally &apos; No reason to risk abort here
1236 Try:
1237 sUrl = SF_String.ReplaceStr(cstURL, Array(&quot;%1&quot;, &quot;%2&quot;), Array(LCase(psService), psMethod))
1238 SF_Session.OpenUrlInBrowser(sUrl)
1240 Finally:
1241 Exit Sub
1242 End Sub &apos; ScriptForge.SF_Exception._OpenHelpInBrowser
1244 REM -----------------------------------------------------------------------------
1245 Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
1246 &apos;&apos;&apos; Return the value of the named property
1247 &apos;&apos;&apos; Args:
1248 &apos;&apos;&apos; psProperty: the name of the property
1250 Dim cstThisSub As String
1251 Const cstSubArgs = &quot;&quot;
1253 cstThisSub = &quot;SF_Exception.get&quot; &amp; psProperty
1255 SF_Exception._CaptureSystemError()
1257 Select Case psProperty
1258 Case &quot;Description&quot;
1259 If _Description = &quot;&quot; Then _PropertyGet = _SysDescription Else _PropertyGet = _Description
1260 Case &quot;Number&quot;
1261 If IsEmpty(_Number) Then _PropertyGet = _SysNumber Else _PropertyGet = _Number
1262 Case &quot;Source&quot;
1263 If IsEmpty(_Source) Then _PropertyGet = _SysSource Else _PropertyGet = _Source
1264 Case Else
1265 _PropertyGet = Null
1266 End Select
1268 Finally:
1269 Exit Function
1270 End Function &apos; ScriptForge.SF_Exception._PropertyGet
1272 REM -----------------------------------------------------------------------------
1273 Private Function _PropertySet(Optional ByVal psProperty As String _
1274 , Optional ByVal pvValue As Variant _
1275 ) As Boolean
1276 &apos;&apos;&apos; Set a new value to the named property
1277 &apos;&apos;&apos; Applicable only to user defined errors
1278 &apos;&apos;&apos; Args:
1279 &apos;&apos;&apos; psProperty: the name of the property
1280 &apos;&apos;&apos; pvValue: the new value
1282 Dim cstThisSub As String
1283 Const cstSubArgs = &quot;&quot;
1285 cstThisSub = &quot;SF_Exception.set&quot; &amp; psProperty
1286 _PropertySet = False
1288 SF_Exception._CaptureSystemError()
1290 &apos; Argument validation must be manual to preserve system error status
1291 &apos; If wrong VarType then property set is ignored
1292 Select Case psProperty
1293 Case &quot;Description&quot;
1294 If VarType(pvValue) = V_STRING Then _Description = pvValue
1295 Case &quot;Number&quot;
1296 Select Case SF_Utils._VarTypeExt(pvValue)
1297 Case V_STRING
1298 _Number = pvValue
1299 Case V_NUMERIC
1300 _Number = CLng(pvValue)
1301 If _Number &lt;= RUNTIMEERRORS And Len(_Description) = 0 Then _Description = Error(_Number)
1302 Case V_EMPTY
1303 _Number = Empty
1304 Case Else
1305 End Select
1306 Case &quot;Source&quot;
1307 Select Case SF_Utils._VarTypeExt(pvValue)
1308 Case V_STRING
1309 _Source = pvValue
1310 Case V_NUMERIC
1311 _Source = CLng(pvValue)
1312 Case Else
1313 End Select
1314 Case Else
1315 End Select
1317 _PropertySet = True
1319 Finally:
1320 Exit Function
1321 End Function &apos; ScriptForge.SF_Exception._PropertySet
1323 REM -----------------------------------------------------------------------------
1324 Private Function _Repr() As String
1325 &apos;&apos;&apos; Convert the Exception instance to a readable string, typically for debugging purposes (DebugPrint ...)
1326 &apos;&apos;&apos; Args:
1327 &apos;&apos;&apos; Return:
1328 &apos;&apos;&apos; &quot;[Exception]: A readable string&quot;
1330 _Repr = &quot;[Exception]: &quot; &amp; _Number &amp; &quot; (&quot; &amp; _Description &amp; &quot;)&quot;
1332 End Function &apos; ScriptForge.SF_Exception._Repr
1334 REM -----------------------------------------------------------------------------
1335 Private Function _RightCase(psString As String) As String
1336 &apos;&apos;&apos; Return the input argument in lower case only when the procedure in execution
1337 &apos;&apos;&apos; has been triggered from a Python script
1338 &apos;&apos;&apos; Indeed, Python requires lower case arguments
1339 &apos;&apos;&apos; Args:
1340 &apos;&apos;&apos; psString: probably an identifier in ProperCase
1341 &apos;&apos;&apos; Return:
1342 &apos;&apos;&apos; The input argument in lower case or left unchanged depending on the execution context
1344 Try:
1345 If _SF_.TriggeredByPython Then _RightCase = LCase(psString) Else _RightCase = psString
1347 Finally:
1348 Exit Function
1349 End Function &apos; ScriptForge.SF_Exception._RightCase
1351 REM -----------------------------------------------------------------------------
1352 Private Function _RightCaseArgs(psString As String) As String
1353 &apos;&apos;&apos; Return the input argument unchanged when the execution context is Basic
1354 &apos;&apos;&apos; When it is Python, the argument names are lowercased.
1355 &apos;&apos;&apos; Args:
1356 &apos;&apos;&apos; psString: one of the cstSubArgs strings located in each official method
1357 &apos;&apos;&apos; Return:
1358 &apos;&apos;&apos; The input string in which the argument names are put in lower case when called from Python scripts
1360 Dim sSubArgs As String &apos; Return value
1361 Dim vArgs As Variant &apos; Input string split on the comma character
1362 Dim sSingleArg As String &apos; Single vArgs item
1363 Dim vSingleArgs As Variant &apos; vSingleArg split on equal sign
1364 Dim i As Integer
1366 Const cstComma = &quot;,&quot;
1367 Const cstEqual = &quot;=&quot;
1369 Try:
1370 If Len(psString) = 0 Then
1371 sSubArgs = &quot;&quot;
1372 ElseIf _SF_.TriggeredByPython Then
1373 vArgs = SF_String.SplitNotQuoted(psString, cstComma, QuoteChar := &quot;&quot;&quot;&quot;)
1374 For i = 0 To UBound(vArgs)
1375 sSingleArg = vArgs(i)
1376 vSingleArgs = Split(sSingleArg, cstEqual)
1377 vSingleArgs(0) = LCase(vSingleArgs(0))
1378 vArgs(i) = join(vSingleArgs, cstEqual)
1379 Next i
1380 sSubArgs = Join(vArgs, cstComma)
1381 Else
1382 sSubArgs = psString
1383 End If
1385 Finally:
1386 _RightCaseArgs = sSubArgs
1387 Exit Function
1388 End Function &apos; ScriptForge.SF_Exception._RightCaseArgs
1390 REM ============================================ END OF SCRIPTFORGE.SF_EXCEPTION
1391 </script:module>