unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, frxDesgn, frxClass, StdCtrls;
type
TForm1 = class(TForm)
frxReport1: TfrxReport;
frxDesigner1: TfrxDesigner;
Button1: TButton;
function frxReport1UserFunction(const MethodName: String;
var Params: Variant): Variant;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses StrUtils;
{$R *.dfm}
function Test1(Arg1, Arg2: string): string;
begin
Result := 'You gave me ' + Arg1 + ' and ' + Arg2 + ' !';
end;
function Test2(Arg1: extended): extended;
begin
Result := Arg1 * Arg1;
end;
function Test3: string;
begin
Result := Application.ExeName;
end;
procedure Test4(S: string);
begin
ShowMessage(S);
end;
function TForm1.frxReport1UserFunction(const MethodName: String;
var Params: Variant): Variant;
begin
if SameText(MethodName, 'Test1') then
Result := test1(Params[0], Params[1])
else if SameText(MethodName, 'Test2') then
Result := Test2(Params[0])
else if SameText(MethodName, 'Test3') then
Result := Test3
else if SameText(MethodName, 'Test4') then
Test4(Params[0]);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
frxReport1.DesignReport;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
frxReport1.AddFunction('function Test1(Arg1, Arg2: string): string' , 'MyFunctions', 'this function takes 2 string and show you both');
frxReport1.AddFunction('function Test2(Arg1: extended): extended' , 'MyFunctions', 'this function square a number');
frxReport1.AddFunction('function Test3: string' , 'MyFunctions', 'this function returns Exe Name');
frxReport1.AddFunction('procedure Test4(S: string)' , 'MyFunctions', 'this procedure shows string');
end;
end.
اینجا رو هم ببینید:
http://www.fast-report.com/public_do..._to_report.htm