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_Services" 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 =======================================================================================================================
11 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
12 ''' SF_Services
13 ''' ===========
14 ''' Singleton class implementing the
"ScriptForge.Services
" service
15 ''' Implemented as a usual Basic module
16 ''' The ScriptForge framework includes
17 ''' the current ScriptForge library
18 ''' a number of
"associated
" libraries
19 ''' any user/contributor extension wanting to fit into the framework
20 ''' The methods in this module constitute the kernel of the ScriptForge framework
21 ''' - RegisterScriptServices
22 ''' Register for a library the list of services it implements
23 ''' Each library in the framework must implement its own RegisterScriptServices method
24 ''' This method consists in a series of invocations of next
2 methods
25 ''' - RegisterService
26 ''' Register a single service
27 ''' - RegisterEventManager
28 ''' Register a single event manager
29 ''' - CreateScriptService
30 ''' Called by user scripts to get an object giving access to a service or to the event manager
32 ''' Detailed user documentation:
33 ''' https://help.libreoffice.org/latest/en-US/text/sbasic/shared/
03/sf_services.html?DbPAR=BASIC
34 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
36 REM ================================================================== EXCEPTIONS
38 Const UNKNOWNSERVICEERROR =
"UNKNOWNSERVICEERROR
" ' Service not found within the registered services of the given library
39 Const SERVICESNOTLOADEDERROR =
"SERVICESNOTLOADEDERROR
" ' Failure during the registering of the services of the given library
40 Const UNKNOWNFILEERROR =
"UNKNOWNFILEERROR
" ' Source file does not exist
42 REM ============================================================== PUBLIC MEMBERS
44 ' Defines an entry in in the services dictionary
47 ServiceType As Integer
50 ' 2 Method reference as a string
51 ServiceReference As Object
52 ServiceMethod As String
53 EventManager As Boolean
' True if registered item is an event manager
56 Private vServicesArray As Variant
' List of services registered by a library
58 REM ============================================================== PUBLIC METHODS
60 REM -----------------------------------------------------------------------------
61 Public Function CreateScriptService(Optional ByRef Service As Variant _
62 , ParamArray pvArgs As Variant _
64 ''' Create access to the services of a library for the benefit of a user script
65 ''' A service is to understand either:
66 ''' as a set of methods gathered in a Basic standard module
67 ''' or a set of methods and properties gathered in a Basic class module
68 ''' Args:
69 ''' Service: the name of the service in
2 parts
"library.service
"
70 ''' The library is a Basic library that must exist in the GlobalScope
71 ''' (default =
"ScriptForge
")
72 ''' The service is one of the services registered by the library
73 ''' thru the RegisterScriptServices() routine
74 ''' pvArgs: a set of arguments passed to the constructor of the service
75 ''' This is only possible if the service refers to a Basic class module
76 ''' Returns
77 ''' The object containing either the reference of the Basic module
78 ''' or of the Basic class instance
79 ''' Both are Basic objects
80 ''' Returns Nothing if an error occurred.
81 ''' ==
>> NOTE: The error can be within the user script creating the new class instance
82 ''' Exceptions:
83 ''' SERVICESNOTLOADEDERROR RegisterScriptService probable failure
84 ''' UNKNOWNSERVICEERROR Service not found
85 ''' Examples
86 ''' CreateScriptService(
"Array
")
87 ''' =
> Refers to ScriptForge.Array or SF_Array
88 ''' CreateScriptService(
"ScriptForge.Dictionary
")
89 ''' =
> Returns a new empty dictionary;
"ScriptForge.
" is optional
90 ''' CreateScriptService(
"SFDocuments.Calc
")
91 ''' =
> Refers to the Calc service, implemented in the SFDocuments library
92 ''' CreateScriptService(
"Dialog
", dlgName)
93 ''' =
> Returns a Dialog instance referring to the dlgName dialog
94 ''' CreateScriptService(
"SFDocuments.Event
", oEvent)
95 ''' =
> Refers to the Document service instance, implemented in the SFDocuments library, having triggered the event
97 Dim vScriptService As Variant
' Return value
98 Dim vServiceItem As Variant
' A single service (see _Service type definition)
99 Dim vServicesList As Variant
' Output of RegisterScriptServices
100 Dim vSplit As Variant
' Array to split argument in
101 Dim sLibrary As String
' Library part of the argument
102 Dim sService As String
' Service part of the argument
103 Dim vLibrary As Variant
' Dictionary of libraries
104 Dim vService As Variant
' An individual service object
105 Const cstThisSub =
"SF_Services.CreateScriptService
"
106 Const cstSubArgs =
"Service, arg0[, arg1] ...
"
108 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
109 Set vScriptService = Nothing
112 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
113 If Not SF_Utils._Validate(Service,
"Service
", V_STRING) Then GoTo Catch
114 If Len(Service) =
0 Then GoTo CatchNotFound
118 ' Initialize the list of services when CreateScriptService called for the very
1st time
119 If IsEmpty(_SF_.ServicesList) Then _SF_.ServicesList = SF_Services._NewDictionary()
121 ' Simple parsing of argument
122 vSplit = Split(Service,
".
")
123 If UBound(vSplit)
> 1 Then GoTo CatchNotFound
124 If UBound(vSplit) =
0 Then
125 sLibrary =
"ScriptForge
" ' Yes, the default value !
127 ' Accept other default values for associated libraries
128 Select Case LCase(sService)
129 Case
"document
",
"calc
",
"writer
",
"base
",
"documentevent
",
"formevent
"
130 sLibrary =
"SFDocuments
"
131 Case
"dialog
",
"dialogevent
" : sLibrary =
"SFDialogs
"
132 Case
"database
",
"datasheet
" : sLibrary =
"SFDatabases
"
133 Case
"unittest
" : sLibrary =
"SFUnitTests
"
134 Case
"menu
",
"popupmenu
" : sLibrary =
"SFWidgets
"
142 With _SF_.ServicesList
144 ' Load the set of services from the library, if not yet done
145 If Not .Exists(sLibrary) Then
146 If Not SF_Services._LoadLibraryServices(sLibrary) Then GoTo CatchNotLoaded
149 ' Find and return the requested service
150 vServicesList = .Item(sLibrary)
151 If Not vServicesList.Exists(sService) Then GoTo CatchNotFound
152 vServiceItem = vServicesList.Item(sService)
153 Select Case vServiceItem.ServiceType
154 Case
1 ' Basic module
155 vScriptService = vServiceItem.ServiceReference
156 Case
2 ' Method to call
157 If sLibrary =
"ScriptForge
" Then
' Direct call
158 Select Case UCase(sService)
159 Case
"DICTIONARY
" : vScriptService = SF_Services._NewDictionary()
160 Case
"L10N
" : vScriptService = SF_Services._NewL10N(pvArgs)
161 Case
"TIMER
" : vScriptService = SF_Services._NewTimer(pvArgs)
164 Else
' Call via script provider
165 Set vService = SF_Session._GetScript(
"Basic
", SF_Session.SCRIPTISAPPLICATION, vServiceItem.ServiceMethod)
166 vScriptService = vService.Invoke(Array(pvArgs()), Array(), Array())
174 CreateScriptService = vScriptService
175 SF_Utils._ExitFunction(cstThisSub)
180 SF_Exception.RaiseFatal(UNKNOWNSERVICEERROR,
"Service
", Service, sLibrary, sService)
183 SF_Exception.RaiseFatal(SERVICESNOTLOADEDERROR,
"Service
", Service, sLibrary)
185 End Function
' ScriptForge.SF_Services.CreateScriptService
187 REM -----------------------------------------------------------------------------
188 Public Function RegisterEventManager(Optional ByVal ServiceName As Variant _
189 , Optional ByRef ServiceReference As Variant _
191 ''' Register into ScriptForge a new event entry for the library
192 ''' from which this method is called
193 ''' MUST BE CALLED ONLY from a specific RegisterScriptServices() method
194 ''' Usually the method should be called only once by library
195 ''' Args:
196 ''' ServiceName: the name of the service as a string. It the service exists
197 ''' already for the library the method overwrites the existing entry
198 ''' ServiceReference: the function which will identify the source of the triggered event
199 ''' something like:
"libraryname.modulename.function
"
200 ''' Returns:
201 ''' True if successful
202 ''' Example:
203 ''' ' Code snippet stored in a module contained in the SFDocuments library
204 ''' Sub RegisterScriptServices()
205 ''' ' Register the events manager of the library
206 ''' RegisterEventManager(
"DocumentEvent
",
"SFDocuments.SF_Register._EventManager
")
207 ''' End Sub
208 ''' ' Code snippet stored in a user script
209 ''' Sub Trigger(poEvent As Object)
' Triggered by a DOCUMENTEVENT event
210 ''' Dim myDoc As Object
211 ''' ' To get the document concerned by the event:
212 ''' Set myDoc = CreateScriptService(
"SFDocuments.DocumentEvent
", poEvent)
213 ''' End Sub
215 Dim bRegister As Boolean
' Return value
216 Const cstThisSub =
"SF_Services.RegisterEventManager
"
217 Const cstSubArgs =
"ServiceName, ServiceReference
"
219 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
223 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
224 If Not SF_Utils._Validate(ServiceName,
"ServiceName
", V_STRING) Then GoTo Finally
225 If Not SF_Utils._Validate(ServiceReference,
"ServiceReference
",V_STRING) Then GoTo Finally
229 bRegister = _AddToServicesArray(ServiceName, ServiceReference, True)
232 RegisterEventManager = bRegister
233 SF_Utils._ExitFunction(cstThisSub)
237 End Function
' ScriptForge.SF_Services.RegisterEventManager
239 REM -----------------------------------------------------------------------------
240 Public Function RegisterService(Optional ByVal ServiceName As Variant _
241 , Optional ByRef ServiceReference As Variant _
243 ''' Register into ScriptForge a new service entry for the library
244 ''' from which this method is called
245 ''' MUST BE CALLED ONLY from a specific RegisterScriptServices() method
246 ''' Args:
247 ''' ServiceName: the name of the service as a string. It the service exists
248 ''' already for the library the method overwrites the existing entry
249 ''' ServiceReference: either
250 ''' - the Basic module that implements the methods of the service
251 ''' something like: GlobalScope.Library.Module
252 ''' - an instance of the class implementing the methods and properties of the service
253 ''' something like:
"libraryname.modulename.function
"
254 ''' Returns:
255 ''' True if successful
257 Dim bRegister As Boolean
' Return value
258 Const cstThisSub =
"SF_Services.RegisterService
"
259 Const cstSubArgs =
"ServiceName, ServiceReference
"
261 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
265 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
266 If Not SF_Utils._Validate(ServiceName,
"ServiceName
", V_STRING) Then GoTo Finally
267 If Not SF_Utils._Validate(ServiceReference,
"ServiceReference
", Array(V_STRING, V_OBJECT)) Then GoTo Finally
271 bRegister = _AddToServicesArray(ServiceName, ServiceReference, False)
274 RegisterService = bRegister
275 SF_Utils._ExitFunction(cstThisSub)
279 End Function
' ScriptForge.SF_Services.RegisterService
281 REM -----------------------------------------------------------------------------
282 Public Sub RegisterScriptServices() As Variant
283 ''' Register into ScriptForge the list of the services implemented by the current library
284 ''' Each library pertaining to the framework must implement its own version of this method
285 ''' This method may be stored in any standard (i.e. not class-) module
287 ''' Each individual service is registered by calling the RegisterService() method
289 ''' The current version is given as an example
291 With GlobalScope.ScriptForge.SF_Services
292 .RegisterService(
"Array
", GlobalScope.ScriptForge.SF_Array)
' Reference to the Basic module
293 .RegisterService(
"Dictionary
",
"ScriptForge.SF_Services._NewDictionary
")
' Reference to the function initializing the service
294 .RegisterService(
"Exception
", GlobalScope.ScriptForge.SF_Exception)
295 .RegisterService(
"FileSystem
", GlobalScope.ScriptForge.SF_FileSystem)
296 .RegisterService(
"L10N
",
"ScriptForge.SF_Services._NewL10N
")
297 .RegisterService(
"Platform
", GlobalScope.ScriptForge.SF_Platform)
298 .RegisterService(
"Region
", GlobalScope.ScriptForge.SF_Region)
299 .RegisterService(
"Session
", GlobalScope.ScriptForge.SF_Session)
300 .RegisterService(
"String
", GlobalScope.ScriptForge.SF_String)
301 .RegisterService(
"Timer
",
"ScriptForge.SF_Services._NewTimer
")
302 .RegisterService(
"UI
", GlobalScope.ScriptForge.SF_UI)
306 End Sub
' ScriptForge.SF_Services.RegisterScriptServices
308 REM =========================================================== PRIVATE FUNCTIONS
310 REM -----------------------------------------------------------------------------
311 Private Function _AddToServicesArray(ByVal psServiceName As String _
312 , ByRef pvServiceReference As Variant _
313 , ByVal pbEvent As Boolean _
315 ''' Add the arguments as an additional row in vServicesArray (Public variable)
316 ''' Called from RegisterService and RegisterEvent methods
318 Dim bRegister As Boolean
' Return value
319 Dim lMax As Long
' Number of rows in vServicesArray
324 ' Ignore when method is not called from RegisterScriptServices()
325 If IsEmpty(vServicesArray) Or IsNull(vServicesArray) Or Not IsArray(vServicesArray) Then GoTo Finally
328 lMax = UBound(vServicesArray,
1) +
1
330 ReDim vServicesArray(
0 To
0,
0 To
2)
332 ReDim Preserve vServicesArray(
0 To lMax,
0 To
2)
334 vServicesArray(lMax,
0) = psServiceName
335 vServicesArray(lMax,
1) = pvServiceReference
336 vServicesArray(lMax,
2) = pbEvent
340 _AddToServicesArray = bRegister
342 End Function
' ScriptForge.SF_Services._AddToServicesArray
344 REM -----------------------------------------------------------------------------
345 Private Function _FindModuleFromMethod(ByVal psLibrary As String _
346 , ByVal psMethod As String _
348 ''' Find in the given library the name of the module containing
349 ''' the method given as
2nd argument (usually RegisterScriptServices)
350 ''' Args:
351 ''' psLibrary: the name of the Basic library
352 ''' psMethod: the method to locate
353 ''' Returns:
354 ''' The name of the module or a zero-length string if not found
356 Dim vCategories As Variant
' "user
" or
"share
" library categories
357 Dim sCategory As String
358 Dim vLanguages As Variant
' "Basic
",
"Python
", ... programming languages
359 Dim sLanguage As String
360 Dim vLibraries As Variant
' Library names
361 Dim sLibrary As String
362 Dim vModules As Variant
' Module names
363 Dim sModule As String
' Return value
364 Dim vMethods As Variant
' Method/properties/subs/functions
365 Dim sMethod As String
366 Dim oRoot As Object
' com.sun.star.script.browse.BrowseNodeFactory
367 Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer
369 _FindModuleFromMethod =
""
370 Set oRoot = SF_Utils._GetUNOService(
"BrowseNodeFactory
").createView(com.sun.star.script.browse.BrowseNodeFactoryViewTypes.MACROORGANIZER)
372 ' Exploration is done via tree nodes
373 If Not IsNull(oRoot) Then
374 If oRoot.hasChildNodes() Then
375 vCategories = oRoot.getChildNodes()
376 For i =
0 To UBound(vCategories)
377 sCategory = vCategories(i).getName()
378 ' Consider
"My macros
& Dialogs
" and
"LibreOffice Macros
& Dialogs
" only
379 If sCategory =
"user
" Or sCategory =
"share
" Then
380 If vCategories(i).hasChildNodes() Then
381 vLanguages = vCategories(i).getChildNodes()
382 For j =
0 To UBound(vLanguages)
383 sLanguage = vLanguages(j).getName()
384 ' Consider Basic libraries only
385 If sLanguage =
"Basic
" Then
386 If vLanguages(j).hasChildNodes() Then
387 vLibraries = vLanguages(j).getChildNodes()
388 For k =
0 To UBound(vLibraries)
389 sLibrary = vLibraries(k).getName()
390 ' Consider the given library only
391 If sLibrary = psLibrary Then
392 If vLibraries(k).hasChildNodes() Then
393 vModules = vLibraries(k).getChildNodes()
394 For l =
0 To UBound(vModules)
395 sModule = vModules(l).getName()
396 ' Check if the module contains the targeted method
397 If vModules(l).hasChildNodes() Then
398 vMethods = vModules(l).getChildNodes()
399 For m =
0 To UBound(vMethods)
400 sMethod = vMethods(m).getName()
401 If sMethod = psMethod Then
402 _FindModuleFromMethod = sModule
420 End Function
' ScriptForge.SF_Services._FindModuleFromMethod
422 REM -----------------------------------------------------------------------------
423 Private Function _LoadLibraryServices(ByVal psLibrary As String) As Boolean
424 ''' Execute psLibrary.RegisterScriptServices() and load its services into the persistent storage
425 ''' Args:
426 ''' psLibrary: the name of the Basic library
427 ''' Library will be loaded if not yet done
428 ''' Returns:
429 ''' True if success
430 ''' The list of services is loaded directly into the persistent storage
433 Dim vServicesList As Variant
' Dictionary of services
434 Dim vService As Variant
' Single service entry in dictionary
435 Dim vServiceItem As Variant
' Single service in vServicesArray
436 Dim sModule As String
' Name of module containing the RegisterScriptServices method
438 Const cstRegister =
"RegisterScriptServices
"
441 _LoadLibraryServices = False
443 vServicesArray = Array()
445 If psLibrary =
"ScriptForge
" Then
447 ScriptForge.SF_Services.RegisterScriptServices()
449 ' Register services via script provider
450 If GlobalScope.BasicLibraries.hasByName(psLibrary) Then
451 If Not GlobalScope.BasicLibraries.isLibraryLoaded(psLibrary) Then
452 GlobalScope.BasicLibraries.LoadLibrary(psLibrary)
457 sModule = SF_Services._FindModuleFromMethod(psLibrary, cstRegister)
458 If Len(sModule) =
0 Then GoTo Finally
459 SF_Session.ExecuteBasicScript(, psLibrary
& ".
" & sModule
& ".
" & cstRegister)
462 ' Store in persistent storage
463 ' - Create list of services for the current library
464 Set vServicesList = SF_Services._NewDictionary()
465 For i =
0 To UBound(vServicesArray,
1)
466 Set vService = New _Service
468 .ServiceName = vServicesArray(i,
0)
469 vServiceItem = vServicesArray(i,
1)
470 If VarType(vServiceItem) = V_STRING Then
472 .ServiceMethod = vServiceItem
473 Set .ServiceReference = Nothing
476 .ServiceMethod =
""
477 Set .ServiceReference = vServiceItem
479 .EventManager = vServicesArray(i,
2)
481 vServicesList.Add(vServicesArray(i,
0), vService)
483 ' - Add the new dictionary to the persistent dictionary
484 _SF_.ServicesList.Add(psLibrary, vServicesList)
485 _LoadLibraryServices = True
486 vServicesArray = Empty
490 End Function
' ScriptForge.SF_Services._LoadLibraryServices
492 REM -----------------------------------------------------------------------------
493 Public Function _NewDictionary() As Variant
494 ''' Create a new instance of the SF_Dictionary class
495 ''' Returns: the instance or Nothing
499 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
504 Set oDict = New SF_Dictionary
505 Set oDict.[Me] = oDict
508 Set _NewDictionary = oDict
513 End Function
' ScriptForge.SF_Services._NewDictionary
515 REM -----------------------------------------------------------------------------
516 Public Function _NewL10N(Optional ByVal pvArgs As Variant) As Variant
517 ''' Create a new instance of the SF_L10N class
519 ''' FolderName: the folder containing the PO files in SF_FileSystem.FileNaming notation
520 ''' Locale: locale of user session (default) or any other valid la{nguage]-CO[UNTRY] combination
521 ''' The country part is optional. Valid are f.i.
"fr
",
"fr-CH
",
"en-US
"
522 ''' Encoding: The character set that should be used
523 ''' Use one of the Names listed in https://www.iana.org/assignments/character-sets/character-sets.xhtml
524 ''' Note that LibreOffice probably does not implement all existing sets
525 ''' Default = UTF-
8
526 ''' Locale2: fallback Locale to select if Locale po file does not exist (typically
"en-US
")
527 ''' Encoding2: Encoding of the
2nd Locale file
528 ''' Returns: the instance or Nothing
529 ''' Exceptions:
530 ''' UNKNOWNFILEERROR The PO file does not exist
532 Dim oL10N As Variant
' Return value
533 Dim sFolderName As String
' Folder containing the PO files
534 Dim sLocale As String
' Passed argument or that of the user session
535 Dim sLocale2 As String
' Alias for Locale2
536 Dim oLocale As Variant
' com.sun.star.lang.Locale
537 Dim sPOFile As String
' PO file must exist
538 Dim sEncoding As String
' Alias for Encoding
539 Dim sEncoding2 As String
' Alias for Encoding2
541 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
544 If IsMissing(pvArgs) Then pvArgs = Array()
545 sPOFile =
""
546 sEncoding =
""
547 If UBound(pvArgs)
>=
0 Then
548 If Not SF_Utils._ValidateFile(pvArgs(
0),
"Folder (Arg0)
", , True) Then GoTo Catch
549 sFolderName = pvArgs(
0)
550 sLocale =
""
551 If UBound(pvArgs)
>=
1 Then
552 If Not SF_Utils._Validate(pvArgs(
1),
"Locale (Arg1)
", V_STRING) Then GoTo Catch
555 If Len(sLocale) =
0 Then
' Called from Python, the Locale argument may be the zero-length string
556 Set oLocale = SF_Utils._GetUNOService(
"OfficeLocale
")
557 sLocale = oLocale.Language
& "-
" & oLocale.Country
559 If UBound(pvArgs)
>=
2 Then
560 If IsMissing(pvArgs(
2)) Or IsEmpty(pvArgs(
2)) Then pvArgs(
2) =
"UTF-
8"
561 If Not SF_Utils._Validate(pvArgs(
2),
"Encoding (Arg2)
", V_STRING) Then GoTo Catch
562 sEncoding = pvArgs(
2)
564 sEncoding =
"UTF-
8"
566 sLocale2 =
""
567 If UBound(pvArgs)
>=
3 Then
568 If Not SF_Utils._Validate(pvArgs(
3),
"Locale2 (Arg3)
", V_STRING) Then GoTo Catch
571 If UBound(pvArgs)
>=
4 Then
572 If Not SF_Utils._Validate(pvArgs(
4),
"Encoding2 (Arg4)
", V_STRING) Then GoTo Catch
573 sEncoding2 = pvArgs(
4)
575 sEncoding2 =
"UTF-
8"
577 If Len(sFolderName)
> 0 Then
578 sPOFile = SF_FileSystem.BuildPath(sFolderName, sLocale
& ".po
")
579 If Not SF_FileSystem.FileExists(sPOFile) Then
580 If Len(sLocale2) =
0 Then GoTo CatchNotExists
' No fallback =
> error
581 ' Try the fallback
582 sPOFile = SF_FileSystem.BuildPath(sFolderName, sLocale2
& ".po
")
583 If Not SF_FileSystem.FileExists(sPOFile) Then GoTo CatchNotExists
584 sEncoding = sEncoding2
590 Set oL10N = New SF_L10N
591 Set oL10N.[Me] = oL10N
592 oL10N._Initialize(sPOFile, sEncoding)
601 SF_Exception.RaiseFatal(UNKNOWNFILEERROR,
"FileName
", sPOFile)
603 End Function
' ScriptForge.SF_Services._NewL10N
605 REM -----------------------------------------------------------------------------
606 Public Function _NewTimer(Optional ByVal pvArgs As Variant) As Variant
607 ''' Create a new instance of the SF_Timer class
608 ''' Args:
609 ''' [
0] : If True, start the timer immediately
610 ''' Returns: the instance or Nothing
612 Dim oTimer As Variant
' Return value
613 Dim bStart As Boolean
' Automatic start ?
615 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
618 If IsMissing(pvArgs) Then pvArgs = Array()
619 If UBound(pvArgs)
< 0 Then
622 If Not SF_Utils._Validate(pvArgs(
0),
"Start (Arg0)
", V_BOOLEAN) Then GoTo Catch
626 Set oTimer = New SF_Timer
627 Set oTimer.[Me] = oTimer
628 If bStart Then oTimer.Start()
631 Set _NewTimer = oTimer
636 End Function
' ScriptForge.SF_Services._NewTimer
638 REM ============================================== END OF SCRIPTFORGE.SF_SERVICES