![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#3
|
|||
|
|||
|
Te pongo una UDF hecha en Pascal por mi hace unos meses, espero te sirva como ejemploo:
library aam; { Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. } uses SysUtils, ib_util, Classes; function ftstr(v:real):string;stdcall begin result:=FormatFloat('#,##0.00',v); end; function ceros(var n:integer;var s:integer): PChar;stdcall; var i: Integer; sz:string; begin sz:=IntToStr(n); For i:=0 to s-(Length(sz)) do sz:='0'+sz; i := 0; result := pchar(sz); end; function DoubleToStr(var n ouble;var al:integer): PChar;stdcall;var i,j,k: Integer; sz,temp:string; begin i := 0; temp:=''; sz:=trim(FormatFloat('$#,##0.00',n)); j:=13-length(sz); for k:=j downto 1 do temp:=temp+' '; temp:=temp+sz; if al=1 then result := pchar(temp) else result := pchar(sz); end; exports ceros,DoubleToStr; {$R *.res} begin end. ----------------------------------------------------------------------- Y se anexa a Firebird de la sig. forma: DECLARE EXTERNAL FUNCTION CEROS INTEGER, INTEGER RETURNS CSTRING(10) ENTRY_POINT 'ceros' MODULE_NAME 'aam' ------------------------------------------------------------- Y se usa: Select ceros(mi_campo_numerico,1) from mi_tabla Y debe regresar: 10.2 convierte a $10.20 Última edición por Sinaloense fecha: 03-12-2004 a las 19:33:43. |
|
|
|