|
<< Click to Display Table of Contents >>
Global Functions |
In addition to pre-defined functions of VBScript language, such as CreateObject, Chr, CLng, and Replace, among others, this Driver defines the global functions described on the next table.
Global functions
Function |
Description |
|---|---|
NewValue(Value, Quality, TimeStamp) |
Creates an object with a Value (Value Object) type, which contains a value, a quality, and a timestamp. The Quality and TimeStamp parameters are optional and, if not specified, assume the values 192 and Now(), respectively |
Trace(String) |
Writes a message to this Driver's log file |
CreateDotNetObject(String, String) |
Creates an object with a .NET type. The first parameter corresponds to the full path of a .NET assembly and the second parameter refers to the name available in that assembly, including its Namespace, separated by a dot, such as "Namespace.Class". The return of this function is the object created. NOTE: The .NET assembly created must be configured to communicate via COM interface, that is, with the ComVisible attribute enabled. The CreateDotNetObject function supports assemblies compiled using .NET framework version 3.5 or earlier |
The next code contains an example of using global functions.
Dim obj
Sub OnStart()
Set obj = CreateDotNetObject("C:\MyAssembly.dll", "MyNamespace.MyClass")
obj.MyClassMethod()
End Sub
Sub OnRead_List(r, v)
v.DimAsList()
Dim tStamp
tStamp = Now() - 2 'The day before yesterday
Trace "Returning a list of values"
v.AddToList(NewValue("Yesterday", 192, Now() - 1))
v.AddToList(NewValue("Today"))
v.AddToList(NewValue("Tomorrow", 192, Now() + 1))
End Sub
Sub OnStop()
Set obj = Nothing
End Sub