External Function Declaration

Two files are typically required to create a DLL:

When developing a DLL using a common C/C++ compiler, the source file (.c, .cpp) and the definition file (.def) must be included in the Visual Studio project.

In BDL, all external functions called from a script must be declared before they can be used. This must be done in the external functions section of Silk Performer scripts.

Note: If a DLL file is not located in the Silk Performer installation directory or a directory included in the path specification, you need to add the DLL file to the project’s data files.
Note: The vb.net dll file is not supported.
The following files contain sample scripts. The files can be found in the following folder and its subfolders: C:\Users\Public\Public Documents\Silk Performer <version>\SampleApps\CustomAPI.
  • DemoFunctions.bdf
  • DemoFunctions.dsp
  • demofunctions.cpp
  • DemoFunctions.dll

Script Example

In the following example, the external functions DemoSum and DemoDiff are declared and then called in the TMain transaction.

dll "DemoFunctions.dll"
 
  // function without parameters and return value
  "DemoOutput"
    function Output;
 
  // function declared using C data types
  "DemoSum"
    function Sum(in long, in long): long;
 
  // function declared using BDL data types
  "DemoDiff"
    function Diff(in number, in number): number;
 
// DLL is not located in the Silk Performer directory
dll "C:\\Debug\\Functions.dll"
 
dcltrans

  transaction TMain
  var
    x, y, nSum, nDiff: number;
  begin
    x := 4; y := 5;
    nSum := Sum(x, y); // external function calls
    nDiff := Diff(x, y);
    Output();
  end TransMain;