FastReport 3.0 使用自定义函数

来源:互联网 发布:什么软件看书最好 编辑:程序博客网 时间:2024/06/05 18:36
FastReport 3.0使用自定义函数比2.X多了一个步骤,同时函数没有参数的限制,也更清楚。
假设在onUserfunction事件里响应了MYFUNC函数(摘自官方手册):

function TForm1.frxReport1UserFunction( const MethodName: String ;

var Params: Variant): Variant;

begin

if MethodName = 'MYFUNC' then

Result := MyFunc(Params[0], Params[1])

else if MethodName = 'MYPROC' then

MyProc(Params[0]);

end;

那么,我们只要先注册这个函数,就可以使用了。方法如下:
frxReport1.AddFunction('function MyFunc(s: String; i: Integer): Boolean');

MYFunc函数应该像下边那样实现:

function TForm1.MyFunc(s: String ; i: Integer): Boolean;

begin

  //内容略

end;