为什么我的函数不出现在FastReport函数标签中?
问题描述:
我想在外部单元中实现一些功能并在FastReport脚本中调用它们。我的单位编译正确,但问题是没有功能或程序出现在功能选项卡。任何人都可以建议如何解决这个问题吗?我不确定我是否错过了一些东西。为什么我的函数不出现在FastReport函数标签中?
下面是我的单位代码的一个例子。 FastReport开发人员指南指出实现应该如此。
unit frxCustomFuncs;
interface
var myGlobalVar: primitiveType;
implementation
uses sysUtils, Classes, fs_iinterpreter,
myUnit;
type
TFunctions = class(TfsRTTIModule)
private
function CallMethod(Instance: TObject;
ClassType: TClass; const MethodName: String; var Params: Variant): Variant;
public
constructor Create(AScript: TfsScript); override;
end;
procedure myCustomProcedure(myParam1, myParam2: TdateTime);
var myVar: TMyCustomClass; //declared in myUnit
begin
myVar:= TMyCustomClass.create(myParam1, myParam2);
try
Some code ...
myGlobalVar:= myVar.property;
some code ...
finally
myVar.Free;
end;
end;
{ TFunctions }
function TFunctions.CallMethod(Instance: TObject; ClassType: TClass;
const MethodName: String; var Params: Variant): Variant;
begin
if MethodName = 'myCustomProcedure' then
myCustomProcedure(Params[0], Params[1]);
end;
constructor TFunctions.Create(AScript: TfsScript);
begin
inherited create(AScript);
with AScript do
begin
AddMethod('procedure myCustomProcedure(myParam1, myParam2: TdateTime)',
CallMethod, 'My Functions', 'custom description');
end;
end;
initialization
fsRTTIModules.Add(TFunctions);
end.
答
我的猜测:这个单元存在于你自己的项目中,并且你正在使用IDE中的报表设计器。 IDE中的设计者不知道也不应该知道关于您当前项目的事情。
将该文件添加到设计时间包中,IDE中的Designer应该选择这些功能。
@Raul或运行项目(使用您的单元在uses子句中)并在运行时调用报表设计器,您将看到手册中描述的函数。 – jachguate 2011-02-01 22:33:25