InterBase UDFs in Delphi 3 aka Pulling one's hair out

Has anyone successfully written InterBase 4.2 UDFs with Delphi 3.

I need to write a number of them, mostly character oriented.  I come
from a Clipper '87 background where a character was pretty much
considered the same as a string and I didn't need to care if it was
char, varchar, pchar, string,  pstring or G-STRING.  It was all the
same to me, well almost.

I want to write a udf  "ibTrim"   that will receive either a CHAR(x)
or VARCHAR(x) and return it trimmed of trailing spaces into a
VARCHAR(y).  The logic to do the t{*word*220} is easy enough, I'm just not
sure what the parameters need to look like.

    externalTable.Desc    CHAR(255)
    internalTable.Desc     VARCHAR(255)

I want to be able to use the following INSERT to load Desc from an
externalTable into an internalTable.

  INSERT INTO internalTable (Desc)
     SELECT  ibTrim(Desc)                       /* Note ibTrim() */
     FROM externalTable;
I've written the function into a dll and tested it within D3 passing
and receiving edit.Text strings and that works fine.  I used:

    function ibTrim(InString: String): String; export;

I know that these strings aren't going to match up with the CHAR &
VARCHAR very well.  That is, after I take care of my first problem,
which is (boy, can this guy go on and on and on an...) the database
won't recognize my ibTrim function.

IBTrim() is in \Harvest\Bin\IBFunLib.dll and it has been successfully
declared in the database with:

        RETURNS VARCHAR(255)
        MODULE_NAME "\Harvest\Bin\IBFunLib.dll" ;

And I get the following message when I try the INSERT:

Statement failed, SQLCODE = -104
invalid request BLR at offset 18
-function IBTRIM is not defined
-module name or entrypoint could not be found

HELP!!! Please.

Bill (The Energizer Bunny) Meaney
Technical Director
TPMS, Inc.