Adding function libraries
You can add new functions to the Evaluate component by creating new function libraries. The Evaluate component enumerates the functions of all registered function libraries.
Functions should be implemented as standard DLL entry points and exposed using a COM type library as follows:
▪Multiple functions can exist in a single library.
▪Each function should be defined as part of a COM interface, implemented by a COM coclass in the library. This means that global functions aren't supported.
▪There might be multiple coclasses/interfaces in the library, so you can group related functions together. However, each coclass must implement only one interface. In a script or expression, there is no function namespacing and functions are referred to simply by their name, without using the name of their coclass, interface or type library. This means that functions in a type library must have unique names (ignoring any hidden-parameter prefixes), even if they're defined in different interfaces.
▪Each function must be a method of its interface, not a property. In IDL, this means it must not have a [propget], [propput], or [propputref] attribute. In Visual Basic, it must be a Function, not a Property Get, Property Let or Property Set.
▪Each function must return a value, otherwise the Evaluate component will ignore it. In IDL, this means it must have a [retval] parameter. In Visual Basic, it must be a Function, not a Sub.
▪Functions must not have more than one return value. Functions that have more than one out parameter are not supported by the Evaluate component and mrScript engine.
Argument and return value data types
The data types that are supported as parameters and return values are string, long, double, date, Boolean, variant, and array of variants.
The data types that are supported as return values are string, long, double, date, Boolean, variant, array of variants, and custom interfaces.
A categorical value is handled as an array of variants where the variants contain long values. Variants (including those in arrays) used as arguments or return values might contain data types other than long (such as pointers to objects). The function should check the variant type and handle it appropriately. Variant arguments might be passed in as ByRef variants, so the function should be prepared for them.
Where more than one type is allowed for an argument or return value, it should be declared as variant, and the function should check the type.
When used in an SQL expression, only values of the types supported by the Data Model are available (these are Text, Long, Double, Date, Boolean, Categorical). But when used in a scripting environment, objects can be passed in for a variant argument, such as an MDM VariableInstance, an Elements collection, a file-system object, and so on. (Declaring a parameter as Object is theoretically possible but has not been tested.)
Functions with optional arguments, variable arguments, and arguments with default values are supported.
Microsoft OLE/COM Object Viewer
Use the Microsoft OLE/COM Object Viewer tool (OleView.exe) to determine if parameters and return values are in accordance with the functional design. For more information, see:
1 Open OleView.exe, and then click File > View TypeLib > Open <TypeLib>.
2 Open the appropriate Function Library.
3 The tool returns definitions for the Co classes, methods, and other information.
If the Function Library is implemented with Visual Basic or Visual C#, TypeLib should be <filename>.tlb.
If the Function Library is implemented with Visual C++, TypeLib should be <filename>.dll.
See also