Subject Re: [firebird-support] UDF doesn't work - Delphi/fpc
Author Helen Borrie
At 08:12 PM 10/09/2007, you wrote:
>fb 2.01
>
>function YDA_StrNPos(ASubStr, AStr: PChar; var AOccurrenceNo:
>LongInt): LongInt; stdcall; export;
>begin
> Result := StrNPos(String(ASubStr), String(AStr), LongInt(AOccurrenceNo));
>end;
>
>declare external function YDA_StrNPos
>varchar(255), varchar(255), integer
>returns integer by value
>entry_point 'YDA_StrNPos' module_name 'ydafbudf';
>
>select yda_strnpos('abc', '12abc34a5abc678ab', 2) from rdb$database;
>returns 0 (should be 10). It turns out that AOccurrenceNo is received
>correctly but ASubStr and AStr are not.

1. Use cdecl calling convention, not stdcall.

2. declare the strings not as varchar but as the special interface
type cstring.

./heLen