|
Making scripting faster |
This page in 2007 Top Previous Next |
|
Example 1: Basic Use To introduce OAK scripting as simply as possible, we intentionally provided an example code fragment that had as few lines as possible. Option Explicit Sub Main() Example 2: Caching the COM Object The CreateObject step is relatively expensive. If you are going to use OAK scripting intensively, it is a good plan to cache this item so that the object only gets created once in a session. Option Explicit Private oakObject As Operis_OAK.IOAKAddIn Function MyOAKAddIn as Operis_OAK.IOAKAddIn Sub Main() The IOAKAPI object can be cached similarly. Option Explicit Private oakObject As Operis_OAK.IOAKAPI Function MyOAKAPI as Operis_OAK.IOAKAPI Sub Main() Example 3: Modules and Properties Since the OAK COM class implements both the IOAKAPI and IOAKAddIn interfaces, the same cached object can be used for both: Module: OperisAnalysisKit Option Explicit Private oakObject As Object Private Function GetOAKObject() As Object Public Property Get API() As Operis_OAK.IOAKAPI Public Property Get UI() As Operis_OAK.IOAKAddIn Module: OtherModule Option Explicit Public Sub UseOAK1() Public Sub UseOAK2()
|