Custom Method no longer work in FR3.21

edited 10:28PM in FastReport 3.0
Since I upgraded from FR 3.16 to FR3.21 my custom functions no longer appear.

My functions are added uing fsGlobalUnit.AddMethod and worked properly with FR3.16.

Has anybody else had this problem?



Comments

  • edited 10:28PM
    fsGlobalUnit doesn't use.

    1) Before prepare report do this frxReport1.Parent := fsGlobalUnit;
    2)Change registration code to:
    type
      TFunctions = class(TfsRTTIModule)
      private
        function CallMethod(Instance: TObject; ClassType: TClass;
          const MethodName: String; Caller: TfsMethodHelper): Variant;
      public
        constructor Create(AScript: TfsScript); override;
      end;
    
    
    { TFunctions }
    
    constructor TFunctions.Create(AScript: TfsScript);
    begin
      inherited Create(AScript);
      with AScript do
      begin
          AddMethod('procedure ExecSQL', CallMethod);
      end;
    end;
    
    CallMethod(Instance: TObject; ClassType: TClass;const MethodName: String; var Params: Variant): Variant;
    begin
      Result := 0;
        if MethodName = 'EXECSQL' then
        // do something
    end;
    
    
    initialization
      fsRTTIModules.Add(TFunctions);
    
    end.
    
  • renerene Prague, Czech Republic, Europe
    edited 10:28PM
    Note for FR developers: Please correct the manuals too ( FR manuals). Old approach is still compilable, but no longer functionable (I tried to write my first new component and because the developer manual was obsolete I was debugging totaly insane things). Maybe better approach is to strictly remove old contructions (even if they are in some way functionable). When I want to apply some components uprgade / update I have to be prepared for some source changes (better to change three type of calls in whole project than compilable code which is not valid).
    ;)

Leave a Comment