Subject RE: [ib-support] UDF Problems
Author Doug Chamberlin
At 9/13/2001 04:51 AM (Thursday), Gerhardus Geldenhuis wrote:
>If only some of your parameters is var then it does not work. All of them
>must be var parameters in order for it to work.

If all IB passes are pointers to arguments then all your parameter
declarations must be pointers. The easiest way to handle this is to declare
them as "var". However, declaring them as non-var types should also work.

>There is one problem piece of code still left. Which causes the connection
>to be lost.
>Here it is:
>function CostPrice(var Width,Height,RF,WF:Integer;var CP:Double;var
>Operation,CalcType:PChar):Double;
>var
> K:Double;
> Op,CT:String;
>begin
> Op:=String(Operation);
> Op:=TrimLeft(UpperCase(Op));
> CT:=String(CalcType);
> CT:=TrimLeft(UpperCase(CT));
>...
>If I comment out the conversion part then it works fine.

The declarations of Operation and CalcType look suspicious to me. As they
are above they are declared as "pointer to pointer to char". That may not
match what is being passed.

Here is the declaration from a UDF I just dung up from my archives:
function DLA_LOWER(pStr: PChar): PChar; cdecl; export;

This function receives a string argument and returns a string argument.

Here's how it is declared in the database:
DECLARE EXTERNAL FUNCTION LOWER CSTRING(255)
RETURNS CSTRING(255)
ENTRY_POINT "DLA_LOWER"
MODULE_NAME "DLAUDF";

So, I would conclude that you should use "var" for the non-string
parameters and remove it from the string params.