Subject UDF doesn't work - Delphi/fpc
Author constantijnw
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.

Any clues?