Siebel eScript Language Reference > Methods Reference > Siebel Library Methods >

Siebel Library Call DLL Method


The Siebel Library Call DLL method calls a procedure from a dynamic link library in Microsoft Windows or a shared object in UNIX. It returns an integer.

Windows Format

SElib.dynamicLink(Library, Procedure, Convention[, [desc,] arg1, arg2, arg3, ..., argn])

UNIX Format

SElib.dynamicLink(Library, Procedure[, arg1, arg2, arg3, ...argn])

In UNIX, Siebel CRM cannot use the Siebel Library Call DLL method to pass more than 22 arguments. These 22 arguments include the shared library name and the procedure name. You can configure Siebel CRM to pass up to 20 more arguments.

Table 118 describes the arguments for the Siebel Library Call DLL method.

Table 118. Arguments for the Siebel Library Call DLL Method
Argument
Description

Library

The library argument can include the following:

  • In Microsoft Windows, the name of the DLL that contains the procedure.
  • In UNIX, the name of a shared object. You must specify the fully qualified path name.

Procedure

The name or ordinal number of the procedure in the library dynamic link method.

Convention

The calling convention.

desc

Passes a Unicode string. For example, WCHAR.

arg1, arg2, arg3, ..., argn

Arguments for the Siebel Library Call DLL method.

Usage for the Convention Argument

Table 119 describes the calling conventions you must use with the Siebel Library Call DLL method.

Table 119. Calling Conventions for the Siebel Library Call DLL Method
Value
Description

CDECL

Send the argument that appears last in the list first. For example, consider the following format:

SElib.dynamicLink(Library, Procedure, Convention[, [desc,] arg1, arg2, arg3])

If arg1, arg2, and arg3 are defined, then this method sends the arguments in the following order:

  • arg3
  • arg2
  • arg1

The caller reads the arguments.

The STDCALL value is almost always used in Win32.

STDCALL

PASCAL

Send the argument that appears first in the list first. For example, consider the following format:

SElib.dynamicLink(Library, Procedure, Convention[, [desc,] arg1, arg2, arg3])

If arg1, arg2, and arg3 are defined, then this method sends the arguments in the following order:

  • arg1
  • arg2
  • arg3

The callee reads the arguments.

Usage if An Argument Is Not Defined

Siebel CRM passes values as 32-bit values. If an argument is not defined when Siebel CRM calls the Siebel Library Call DLL method, then it assumes that the argument is a 32-bit value. It passes the address of a 32-bit data element to the Siebel Library Call DLL method. This method then sets the value.

Usage If an Argument Is a Structure

SELib is a feature that Siebel eScript uses to call functions in the native DLLs. These DLLs can contain functions implemented in a third party language, such as C or C++. In this situation, an argument can include a structure.

If an argument is a structure, then it must include a structure that defines the binary data types in memory. Siebel CRM does the following:

  1. Copies the structure to a binary buffer.
  2. Calls the method.
  3. Converts the binary data back into the data structure according to the rules defined in the Write BLOB Data method and the Clib Read From File method. It performs data conversion according to the current BigEndianMode setting.

    For more information, see Write BLOB Data Method and Clib Read From File Method.

Example 1

The following example describes a proxy DLL that uses denormalized input values, creates the structure, and calls a method in the destination DLL:

#include <windows.h>
_declspec(dllexport) int __cdecl
score (
   double AGE,
   double AVGCHECKBALANCE,
   double AVGSAVINGSBALANCE,
   double CHURN_SCORE,
   double CONTACT_LENGTH,
   double HOMEOWNER,
   double *P_CHURN_SCORE,
   double *R_CHURN_SCORE,
   char _WARN_[5] )
{
   *P_CHURN_SCORE = AGE + AVGCHECKBALANCE + AVGSAVINGSBALANCE;
   *R_CHURN_SCORE = CHURN_SCORE + CONTACT_LENGTH + HOMEOWNER;
   strcpy(_WARN_, "SFD");
   return(1);
}

Example 2

The following example calls a DLL. This code uses the buffer for pointers and characters:

function TestDLLCall3()
{
   var AGE = 10;
   var AVGCHECKBALANCE = 20;
   var AVGSAVINGSBALANCE = 30;
   var CHURN_SCORE = 40;
   var CONTACT_LENGTH = 50;
   var HOMEOWNER = 60;
   var P_CHURN_SCORE = Buffer(8);
   var R_CHURN_SCORE = Buffer(8);
   var _WARN_ = Buffer(5);

SElib.dynamicLink("jddll.dll", "score", CDECL,
   FLOAT64, AGE,
   FLOAT64, AVGCHECKBALANCE,
   FLOAT64, AVGSAVINGSBALANCE,
   FLOAT64, CHURN_SCORE,
   FLOAT64, CONTACT_LENGTH,
   FLOAT64, HOMEOWNER,
   P_CHURN_SCORE,
   R_CHURN_SCORE,
   _WARN_);

var r_churn_score = R_CHURN_SCORE.getValue(8, "float");
var p_churn_score = P_CHURN_SCORE.getValue(8, "float");
var nReturns = r_churn_score + p_churn_score;
return(nReturns);
}

Other Examples

The following example calls a DLL function in the default codepage:

var sHello = "Hello";
Selib.dynamicLink("MyLib.dll", "MyFunc", CDECL, sHello);

The following example calls a DLL function that passes Unicode strings:

var sHello = "Hello";
Selib.dynamicLink("MyLib.dll", "MyFunc", CDECL, WCHAR, sHello);

The following example calls a DLL function that passes Unicode and nonUnicode strings:

var sHello = "Hello";
var sWorld = "world";
Selib.dynamicLink("MyLib.dll", "MyFunc", CDECL, WCHAR, sHello, sWorld);

The following example calls an external application and passes arguments 0, 0, and 5 to it:

SElib.dynamicLink("shell32", "ShellExecuteA", STDCALL, 0, "open", "c:\\Grabdata.exe", 0, 0, 5).

Related Topics

For more information, see Clib Send Command Method.

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.