- This example is functional for Web.
of this application is used.
Description of ExamDLL example
The example demonstrates usage of the DLL (dynamic linked libraries), their connection with the PROMOTIC system and calling the functions contained in these libraries.
The following objects were created in this example application:
The PmaDll object named "Func" and graphic panel (PmaPanel).
The "Func" object of the PmaDll type serves to access functions in DLL. On its page Dll it is necessary to set the full path to the file of the required library (in this case FuncDLL.dll).
The panel contains two buttons that call the designer's methods MaxDll and SumDll of panel and objects PmgNumber for entering the values and displaying the result
The panel method SumDll
calls the function Sum
from library FuncDLL
that sums two integers.
panel method works the same way with the only difference that when it is called, the Max
function from the FuncDLL
library is runned for finding the maximum from three integers.
In both methods the numbers are passed in method parameters and the result returned back to the panel.
Listing from script:
in the designer's method MaxDll of the "PanelDll" panel:
VBScriptSelect and copy to clipboard
pResult = pMe.Pm("/Func").Fce.Max(Array(CLng(a), CLng(b), CLng(c)))
In this case passing a parameter to the function is a litte bit complicated because the Max
function takes the structure consisting of three integers as a parameter. This structure is created in PROMOTIC
as an array of the length 3. To pass it to the function correctly, each value of the array has to be converted by means of the CLng
function to 4-bytes integers. The reason for this is that in VBScript
each new variable is automatically assigned to corresponding data type. But this type needn't correspond to the type that is required by the library function which can be programmed in another language. Structured data types need to be passed by references. In this case the Max
function is created so that it takes the structure of three numbers of the Integer
type (it means that 3*4 bytes). That's why before calling Max
, each number must be explicitly converted to 4-bytes value of the Long
type. See Syntax description of the declaration file of the DLL library functions
Description of FuncDLL.dll
This library was created in the programming language C++. It offers two functions:
- Sum(a, b) function, whose parameters a, b are two integers passed by value and it returns their sum a+b.
- Max(st) function has st as an input parameter passed by reference that is a data structure consisting of three integer (4-bytes) values. Returns an integer that is their maximum.
The source code of the library in the language C++ is supplied with the example in the FuncDLL.cpp
file. This file is not needed when calling functions from the PROMOTIC system.
To allow PROMOTIC to call functions included in the DLL library, the declaration file needs to be created. This file has to have the same name as the corresponding library but the extension .inc
(in the case the name is FuncDLL.inc
), and it must be located in the same folder as the library. Each its line contains the declaration of one function. It is not needed to declare all functions from the library but only those that are used in the PROMOTIC system. See Syntax description of the declaration file of the DLL library functions