![]() |
![]() |
![]() |
![]() |
![]() |
FTP | ![]() |
![]() |
CCD | ![]() |
![]() |
Buscar | ![]() |
![]() |
Trucos | ![]() |
![]() |
Trabajo | ![]() |
![]() |
Foros | ![]() |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
![]() ¿Alguien puede ayudarme?
Quiero añadir funciones a un FastReport y consigo verlas en el menu de funciones en tiempo de ejecución, pero no consigo que funcionen. He hecho una función muy simple a la que sólo le paso un String y me devuelve el mismo; pero, pase lo que le pase a la función me da un error "calculando la función" y sólo me pone "Abstract error". Por cierto, ¿Alguien sabe como verlas en tiempo desarrollo, o compilación (o como le querais llamar)? Mi unit es la siguiente: unit uFuncionesFR; interface uses Classes, SysUtils, FR_Class, FR_Const, FR_Utils, Math, empresaPropia, Dialogs; type TReportFunctionLibrary = class(TfrFunctionLibrary) private function formatearNumero(cad : String; numDec : integer) : String; public constructor Create; override; procedure inicializar(emp: tEmpresaPropia); procedure DoFunction(FNo: Integer; p1, p2, p3: Variant; var val: Variant); override; function Convertir(const cantidad:double): String; function Otra(a: String): String; end; var empTrabajo: tEmpresaPropia; implementation uses DB, DBClient; { TReportFunctionLibrary } constructor TReportFunctionLibrary.Create; begin // inherited; inherited Create; // Todas las funciones que se quieran añadir al FR se declaran aquí with List do begin Add('F_CONVERTIR'); Add('F_OTRA'); end; // Para que sean públicas en el apartado Functions del FR se declaran en // el AddFunctionDesc AddFunctionDesc('F_CONVERTIR', 'NUEVAS','F_CONVERTIR(<Cantidad>)/Función que convierte la cantidad que se le pasa a la moneda por defecto.'); AddFunctionDesc('F_OTRA', 'NUEVAS','F_OTRA(<Texto>)/Nada de nada.'); end; procedure TReportFunctionLibrary.inicializar(emp: tEmpresaPropia); begin inherited; empTrabajo:= emp; end; procedure TReportFunctionLibrary.DoFunction(FNo: Integer; p1, p2, p3: Variant; var val: Variant); begin inherited; val := 0; // Todas las funciones que se declaren en el create se definen aquí case FNo of 0: val := Convertir(frParser.Calc(p1)); 1: val := Otra(frParser.Calc(p1)); end; end; function TReportFunctionLibrary.Otra(a: String): String; begin showmessage(a); result:=a; end; function TReportFunctionLibrary.Convertir(const cantidad: double): String; var resultado: double; cad: String; tasaCambio: double; begin tasaCambio:=1; resultado:=cantidad * tasaCambio; str(resultado:1:2, cad); resultado:=strToFloat(cad); result:=formatearNumero(floatToStr(resultado),2); end; function TReportFunctionLibrary.formatearNumero(cad : String; numDec : integer) : String; var // variables begin // cuerpo de la función end; initialization frRegisterFunctionLibrary(TReportFunctionLibrary); finalization frUnRegisterFunctionLibrary(TReportFunctionLibrary); end. ¿Alguien ve algo raro? ¿Sabe alguien porqué no me funciona la función "OTRA"? Pase lo que le pase en "a" me da el error: "Abstract Error". Muchas gracias por adelantado. |
|
|
![]() |
|