Subject Re: udf won't do what it should
Author Adam
--- In firebird-support@yahoogroups.com, "martinknappe" <martin@...>
wrote:
>
> hello
> i'm posting this in this forum because in the delphi forum no one was
> able to help me out:
> i've written a udf with delphi for my interbase database and i think
> i've very much followed all the necessary instructions for doing so
> (according to the tutorial under
> http://www.ibphoenix.com/main.nfs?a=ibphoenix&l=;PAGES;NAME='ibp_howto2'
>
> When testing the dll with my own sample application it does exactly
> what it's supposed to do (namely, replace a sequence of characters in
> a widestring by a different sequence of characters)
> You can find the dll project and the one for the sample app under:
>
> http://www1.file-upload.net/download_23.06.06/43lh4z.rar.html
>
> now, the problem comes in when i want to use the function in my
> firebird database. i declared the udf via:
>
> DECLARE EXTERNAL FUNCTION REPLACESUBSTRING
> CSTRING(100),
> CSTRING(100),
> CSTRING(100)
> RETURNS CSTRING(100) FREE_IT
> ENTRY_POINT 'Replace' MODULE_NAME 'MyFirebirdUDFs'
>
> And then, in order to test it, I do the following:
>
> select replacesubstring('Mafter', 'af', 'us') from rdb$database
>
> This should evidently give me 'Muster' as a result. But instead what I
> get is 'Mafter' again. What am I doing wrong here?
>

Martin,

This is not something Firebird will be doing. I do not have TNT
components installed, so it is a little tricky for me to look at your
pas. Nothing stands out too much to me (except the possibility of
returning nil which I have no idea how it will handle.)

Lucky for you it is a simple procedure. Put a few showmessage calls in
and it should quickly become apparent if there is any issues with the
delphi part.

Have you confirmed that you are using the right dll (restart the FB
Service for good measure). A showmessage will also allow you to be
confident of this.

Adam