Subject Re: [firebird-support] udf firebird delphi
Author Martijn Tonies
Hi Marc,

I'm not an expert on writing UDFs at all... but:


> i created this function:
>
> function MixStr(Str:PChar):PChar;

What's the declaration you're using? cdecl?

> var
> i, j : Integer;
> c1 : Char;
> begin
> if (Str = nil) then
> result := nil
> else
> begin
> for i:=Length(Str) downto 1 do

What does Length(Str) return? What is the length of
a PChar in Delphi? According to the Help:
function Length(S): Integer;
S is a string- or array-valued expression.

> begin
> j:=Random(i)+1;
> c1:=Str[i];
> Str[i]:=Str[j];
> Str[j]:=c1;
> end;
> result := Str;
> end;
> end;
>
> under firebirdi declared:
>
> Declare external function f_MixStr cstring(64)
> returns cstring(64) free_it
> entry_point 'MixStr' module_name 'brudflib2.dll';

As you're not grabbing any memory, should you use
FREE_IT?

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com