How to use custom Delphi function in FastReport 4?

2019-06-09 21:42发布

问题:

I want to use custom Delphi function in FastReport that I can use of the function for some frxMemoView in design time. I find some suggestion in web such as Addfunction in fast report but I can't see my function in function tab in FastReport. please help me.

Thanks Hosein

回答1:

The example in then Using Custom Functions in a Report mentioned by TLama works nearly fine.

There a two problems you might have tripped over.

First: Documentation has two bugs in constructor TFunctions.Create; A missing begin, and a supernumerary '
the corrent implementaion would be

constructor TFunctions.Create;
begin
inherited Create(AScript);
with AScript do
   begin
   AddMethod('function MyFunc(s: String; i: Integer): Boolean', CallMethod,
            'My functions', ' MyFunc function always returns True');
   AddMethod('procedure MyProc(s: String)', CallMethod,
            'My functions', ' MyProc procedure does not do anything');
   end;
end;

The second "problem" is you can not expect to see the functions in the IDE by double clicking on the report, the selection is only availble if you call DesignReport at runtime. This option is not available in the limited edition shipped with XE3.

begin
   //......
   frxReport1.DesignReport;
  //......
end;