Kbase 19219: Sample Code - DLLFUNC in Report Builder
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/28/1999 |
|
SUMMARY: Sample Code - DLLFUNC in Report Builder
INTRODUCTION:
If you need to use DLLFUNC() in Report Builder to do complex
calculations, that Report Builder does not support, the following
example will show you How to use DLLFUNC() to access an external
DLL containing C code.
STEP BY STEP DETAILS:
DLLFUNC expects a Boolean return value from the called DLL
function. TRUE to indicate the function executed successfully.
FALSE to idicate an error. If the DLL function executes
succesfully, it should overwrite its input string with the output
string to be returned by the Report Builder DLLFUNC.
The function in the DLL must take a character string as an
argument and return a boolean value. The DLL in the example
contains one function, TestDllFunc. If you pass "dog" to this
function, it changes it to "poodle" and returns TRUE. If you
pass anything else, it returns FALSE, which causes Report Builder
to display "????????".
Here is the sample C code, how to declare the function so that RB
can call it.
#include "windows.h"
BOOL _declspec(dllexport) WINAPI TestDllFunc(LPSTR lpString)
{
if (!lstrcmp(lpString, "dog"))
{
strcpy(lpString, "poodle");
return TRUE;
}
else
return FALSE;
}
#end of code sample
In the Report you insert a calculated field. In the expression
you call the DLL using function DLLFUNC(dll-name, function-name,
string). If you create a Report using Sports database, insert
cust-num field and the following example in an expression of a
calculated field next to cust-num, it shows the word "poodle" for
the customers with even cust-num. It display "????????" for
customers with odd cust-num.
If you compiled the previous code in c:\work\rbdlltest.dll, use
following expression.
dllfunc("c:\work\rbdlltest.dll", "TestDllFunc", iif(((cust-num -
integer(cust-num / 2) * 2) = 0), "dog", "cat"))
REFERENCES TO WRITTEN DOCUMENTATION:
Report Builder User's Guide - Report Builder Functions
AZeman (28-OCT-1999)