[fpc-pascal] Firebird UDF

zaher dirkey parmaja at gmail.com
Sun Mar 16 22:46:15 CET 2008


May be you UDF depend on external library try to View Dependency.

On Sat, Mar 15, 2008 at 4:05 PM, Stephano <patspiper at yahoo.com> wrote:

> >> nothing todo...
> >> ok restart:
> >> library pudf;
> >>
> >> {$mode objfpc}{$H+}
> >>
> >> uses
> >>   Classes,
> >>   p_func in 'p_func.pas';
> >>
> >> exports
> >>   pround name 'p_round';
> >>
> >> {$R pudf.res}
> >>
> >> begin
> >>
> >> //  DECLARE EXTERNAL FUNCTION pround
> >> //   DOUBLE PRECISION, INTEGER
> >> //   RETURNS DOUBLE PRECISION BY VALUE
> >> //  ENTRY_POINT 'pudf_pround'  MODULE_NAME 'pudf';
> >>
> >> end.
> >>
> >> and
> >>
> >> unit p_func;
> >>
> >> {$mode objfpc}{$H+}
> >>
> >> interface
> >>   function p_round(var valore: double; ndec: integer): double; cdecl;
> >>
> >> implementation
> >>
> >> uses
> >>   Classes, SysUtils;
> >>
> >> function p_round(var valore: double; ndec: integer): double; cdecl;
> >> var
> >>   i: integer;
> >>   risultato: double;
> >>   ndivisore: integer;
> >> begin
> >>
> >>   risultato:=3D valore;
> >>   ndivisore:=3D 1;
> >>   for i:=3D 1 to ndec do
> >>   begin
> >>     risultato:=3D risultato*10;
> >>     ndivisore:=3D ndivisore*10;
> >>   end;
> >>
> >>   result:=3D round(risultato)/ndivisore;
> >> end;
> >> end.
> >>
> >> someone can compile and install?
> >>
> >> I can... but when I try to execute
> >>
> >> select round(123.1233, 2) as nrounded from rdb$database
> >>
> >> always some error!!!
>
> - Entry point should be p_round only in this case
>
> - Adding also 'export' in the function declaration should help:
>
> function p_round(var valore: double; ndec: integer): double; cdecl;
> export;
>
> - The following needs to be corrected as well:
> exports p_round name 'p_round';
> _________^
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



-- =

Zaher Dirkey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freepascal.org/lists/fpc-pascal/attachments/20080316/417b=
507a/attachment.htm


More information about the fpc-pascal mailing list