Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Bases de datos > Firebird e Interbase
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #3  
Antiguo 03-12-2004
Sinaloense Sinaloense is offline
Miembro
 
Registrado: oct 2003
Posts: 139
Poder: 23
Sinaloense Va por buen camino
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 nouble;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.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 14:55:59.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi