2011-02-01 30 views
1

我想在外部單元中實現一些功能並在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. 

回答

2

我的猜測:這個單元存在於你自己的項目中,並且你正在使用IDE中的報表設計器。 IDE中的設計者不知道也不應該知道關於您當前項目的事情。

將該文件添加到設計時間包中,IDE中的Designer應該選擇這些功能。

+1

@Raul或運行項目(使用您的單元在uses子句中)並在運行時調用報表設計器,您將看到手冊中描述的函數。 – jachguate 2011-02-01 22:33:25

相關問題