Subject Re: [firebird-support] UDF Problem
Author Robert Tulloch
Kevin Day Programming wrote:

>Have you set in the run parameters section the host application with the
>full path of ibserver?
>
>
Yes.

>I was just looking at the documentation (OpGuide) for ib v6 under Nt (I
>assume W2K and XP) you have to supply -a switch when launching it to do so
>as an application. Hopefully it is still the same for the version you are
>using. So try, additional to the host application setting, -a in the run
>parameters.
>
>
Doesn't help. So I ran ddll with a test app to track down problems. Pain
in the rear. Gave up on Delphi. I have ALWAYS had a big problem with
Delphi and dll's. So I went back to C++ and all works fine now.

Call from IB

select ProperCaseString(NameFirst, '') from members

-----------------------------------------------------------------------
IB Declaration
DECLARE EXTERNAL FUNCTION PROPERCASESTRING
CSTRING(100) CHARACTER SET NONE, CSTRING(100) CHARACTER SET NONE
RETURNS CSTRING(100) CHARACTER SET NONE
ENTRY_POINT 'fn_ProperCaseString' MODULE_NAME 'strudf';

-----------------------------------------------------------------
dll code:

//---------------------------------------------------------------------------
PChar __stdcall fn_ProperCaseString(PChar szSource , PChar szResult)
{
PChar ProperCase;
Char Space = ' ';
szResult = StrLower(szSource);
if (StrLen(szResult) == 0){
return szResult; //ProperCase;
}
for (int i = 0; i < StrLen(szResult); i++) {
szResult[i] = UpCase(szResult[i]);
while ((szResult[i] != Space) && (i < StrLen(szResult))){
i = i++;
}
}
ProperCase = szResult;
return ProperCase;
}

//---------------------------------------------------------------------------

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*
lpReserved)
{
return 1;
}


---------------------------------------------------------------------------------------------------
.h file

extern "C" __declspec(dllexport) PChar __stdcall
fn_ProperCaseString(PChar szSource, PChar szResult);