开发者

Why don't my functions appear in the FastReport function tab?

I am trying to implement some functions in an external unit and call them inside the FastReport script. My unit is properly compiled, but the problem is no function or procedure appears in the functions tab. Can anybody advise how to sort this out? I am not sure if I missed something.

Below is an example of my unit code. The FastReport developer's guide states that the implementation should be like so.

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 ...
        m开发者_Go百科yGlobalVar:= 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.


My guess: That unit lives in your own project and you're using the report designer in the IDE. The Designer in the IDE doesn't know, and shouldn't know, a thing about your current project.

Add the file to a design time package and the Designer in the IDE should pick up on those functions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜