Data Model > Extending the UNICOM Intelligence Data Model > Adding function libraries
 
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 may 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.
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 may contain data types other than long (such as pointers to objects). The function should check the variant type and handle it appropriately. Variant arguments may 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.
See:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms688269%28v=vs.85%29.aspx
1 Open OleView.exe and navigate to File > View TypeLib > Open <TypeLib>.
2 Open the appropriate Function Library.
3 The tool returns definitions for the Co classes, methods, and other information.
Note If the Function Library is implemented with Visual Basic or Visual C#, TypeLib should be <File Name>.tlb. If the Function Library is implemented with Visual C++, TypeLib should be <File Name>.dll.
See also
Function library registration
Functions with hidden parameters
Functions with optional or variable parameters
Name resolution and function precedence
Custom function example
UNICOM Intelligence Function Library
Extending the UNICOM Intelligence Data Model