SBM ModScript Reference → Additional SBM ModScript Features → Calling Functions in a DLL from SBM ModScript → Calling Your Function
Once the library is loaded, you can call your function like any other function call on an object. The function can take as many parameters as you like because they are converted into a Vector of strings when passed to the DLL function. The function also returns an integer. A typical function call might look like the following example:
var v1 = "1"; // Must be string var v2 = to_string(2); sbmLib.CallLibraryFunction( "MyDllFunction", v1, v2 ); // The DLL exports MyDllFunction Ext.WriteStream( "script: " + v1 ); // The DLL can change v1 and v2 Ext.WriteStream( "script: " + to_int(v2) ); // Strings can be converted to integers
The parameters are input and output, and are converted to UTF-8 strings that are sent to the DLL. Up to seven arguments can be passed to the DLL and if more are needed, a Vector can be passed instead. The parameters need to be declared before the CallLibraryFunction, as they are both input and output. If a Vector is not used, all parameters should either be all strings or all Variants.
Example of using a Vector:
var v = ["1","2"]; // creates a Vector sbmLib.CallLibraryFunction( "MyDllFunction", v ); // The DLL exports MyDllFunction Ext.WriteStream( "script: " + v[0] ); // The DLL can change values inside v Ext.WriteStream( "script: " + to_int(v[1]) ); // Strings can be converted to integers
Copyright © 2007–2018 Serena Software, Inc., a Micro Focus company. All rights reserved.