Loading the Library in SBM ModScript

To load a DLL in SBM ModScript, you first need to create an SBM Library object using the CreateObject function call.

var sbmLib = CreateObject("SBMLibrary");

Once the object is created, tell the object which DLL you want to call functions in by calling SetLibraryName on the SBMLibrary object. You can specify the path in one of three ways.

Additionally, if you are going to use an absolute path to specify the library to load, you must also include the extension. The extension is not assumed when using an absolute path; it is only assumed if you are going to rely on the ScriptAppPath.

Once you have told the library object which library you want to load, call LoadLibrary to actually get the library loaded. For example:

sbmLib.LoadLibrary();

LoadLibrary() returns a boolean which indicates the success or failure of the operation. To avoid experiencing a runtime exception, always check the return value of LoadLibrary() prior to calling any functions in the DLL. For example:

if (sbmLib.LoadLibrary()){
  sbmLib.CallLibraryFunction( "my_function" ); 
}