DLLs
EFS has the ability to call functions distributed in DLL (Dynamic Link Library) files.
Working with DLLs
A dynamically linked library (DLL) is a collection of software functions (mini-programs) that can be called by applications or other DLLs. A DLL is what lets many applications share one copy of a routine they all have in common. It can be said that Windows is simply a collection of DLLs.
Sample.efs File That Calls DLL Object
var d = new DLL("d:/testdll/debug/testdll.dll");
d.addFunction("test", DLL.DOUBLE, DLL.CDECL, "Testing123", DLL.INT, DLL.STRING, DLL.FLOAT, DLL.DOUBLE, DLL.BYTE);
function preMain() {
var v = d.call("test", 123, "testing 123", 456, 544, 65);
debugPrint("v = " + v + "\n");
}
function main() {
}
DLL Object in EFS
The DLL object allows you to write formulas that can communicate with a DLL.
Step 1: Create a DLL object.
Syntax:
Var d = new DLL("DllPath");
Sample:
Var d = new DLL("c:/testdll/testdll.dll");
Step 2: Add Functions to be accessed. A DLL may have one more exported functions. Use the addFunction member to access your exported functions.
Syntax:
AddFunction("refname", ReturnType, FunctionDefType, FunctionName, [Parameters…]);
ReturnType is one of:
DLL.DOUBLE
DLL.INT
DLL.SHORT
DLL.FLOAT
FunctionDefType is one of:
DLL.CDECL
DLL.STDCALL
If your C/C++ function uses the __cdecl keyword, use DLL.CDECL
If your C/C++ function uses the __stdcall keyword, use DLL.STDCALL
FunctionName is the name of the C/C++ function being called. Note: Your compiler may mangle the function name. You will need to reference the MAP file generated by the linker to determine the actual name. In some cases the compiler prepends the function name with an underscore "_". In other cases the compiler mangles the function name.
Parameters
DLL.BYTE
DLL.STRING
DLL.SHORT
DLL.INT
DLL.FLOAT
DLL.DOUBLE
DLL.VOID
DLL.FLOATARRAY (float *)
DLL.DOUBLEARRAY (double *)
Sample. The "addFunction" calls corresponds with the following C/C++ function.
d.addFunction("MyCallName", DLL.DOUBLE, DLL.CDECL, "Testing123", DLL.INT, DLL.STRING, DLL.FLOAT, DLL.DOUBLE, DLL.BYTE);
double __declspec(dllexport) __cdecl Testing123(int i1, PCSTR p1, float f1, double d1, BYTE b1) {
}
Note: All functions associated with a DLL object will share an instance. If you want each function to share a separate instance, instantiate multiple DLL objects.
Step 3: Call the Function
Syntax:
d.call("refname", [Parameters]);
Sample: This will call the Testing123 function per Step 2.
d.call("MyCallName", 123, "testing 123", 456, 544, 65);