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