frAddFunctionDesc

Hi,

I work with FastReport 2.54 and I need to add a personal function with frAddFunctionDesc.

In help, your example is :
frAddFunctionDesc('SUMTOSTR', 'My functions', 'SUMTOSTR()/Converts number to its verbal presentation.');

In FR_Class the code is:
procedure frAddFunctionDesc(FuncLibrary: TfrFunctionLibrary; FuncName, Category, Description: String);

The example doesn't corespond to the code ...

Questions:

1) Where may I use the frAddFunctionDesc ? in Initialization ?

2) If yes , what ClassRef can I use ?

Can you send me a real example whick work correctly with 2.54 FastReport ? It's a little urgent


Other:
even if I don't add the functions to the expression editor, I get an error with my code when I launch my report:
I get an "undefined symbol DEBUTMOISPREC"

In DialogForm.Onactivate
begin
DateDebut.Date := [DEBUTMOISPREC];
DateFin.date := [FINMOISPREC];
end

unit UFonctionsFastReport;

interface

uses SysUtils, classes, FR_Class, Dateutils;

type

TFonctionsFastReport = class(TfrFunctionLibrary)
private
function MyDEBUTMOISPREC:TDateTime;
function MyFINMOISPREC:TDateTime;
public
constructor create; override;
procedure DoFunction(FNo: Integer; p1, p2, p3: Variant; var Val: variant); override;
destructor destroy; override;
end;

implementation

{ FonctionsFastReport }

constructor TFonctionsFastReport.create;
begin
inherited create;
List.Add('DEBUTMOISPREC');
List.Add('FINMOISPREC');
end;

destructor TFonctionsFastReport.destroy;
begin
inherited;
end;

procedure TFonctionsFastReport.DoFunction(FNo: Integer; p1, p2, p3: Variant;
var Val: variant);
begin
val := 0;
case FNo of
0: val := MyDEBUTMOISPREC;
1: val := MyFINMOISPREC;
end;
end;

function TFonctionsFastReport.MyDEBUTMOISPREC: TDateTime;
begin
result := IncMonth(Now, -1);
Result := Dateutils.StartOfTheMonth(Result);
end;

function TFonctionsFastReport.MyFINMOISPREC: TDateTime;
begin
result := IncMonth(Now, -1);
Result := Dateutils.EndOfTheMonth(Result);
end;

initialization
frRegisterFunctionLibrary(TFonctionsFastReport);

finalization
frUnRegisterFunctionLibrary(TFonctionsFastReport);

end.

Can you help me on it please ?

Jean-Luc !

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.