3.23 bug fsGlobalUnit is not work

edited 8:24AM in FastReport 3.0
fsGlobalUnit is not work

in 3.18
constructor TfrxReport.Create(AOwner: TComponent);
begin
inherited;
FVersion := FR_VERSION;
FDatasets := TfrxReportDatasets.Create(Self);
FVariables := TfrxVariables.Create;
FScript := TfsScript.Create(nil);
FScript.Parent := fsGlobalUnit;
FScript.ExtendedCharset := True;

in 3.23

constructor TfrxReport.Create(AOwner: TComponent);
begin
inherited;
FVersion := FR_VERSION;
FDatasets := TfrxReportDatasets.Create(Self);
FVariables := TfrxVariables.Create;
FScript := TfsScript.Create(nil);
FScript.ExtendedCharset := True;
FScript.AddRTTI;


unit myfunctions;

interface

implementation

uses SysUtils, Classes, fs_iinterpreter;

type

TFunctions = class (TObject)

private



function CallMethod(Instance: TObject; ClassType: TClass; const

MethodName: String ; var Params: Variant): Variant;


public



constructor Create;

destructor Destroy; override ;


end;


var

Functions: TFunctions;

function MyFunc(s: String ; i: Integer): Boolean;

begin

// necessary logic

end;

procedure MyProc(s: String );

begin

// necessary logic

end ;

{ TFunctions }

constructor TFunctions.Create;

begin

with fsGlobalUnit do

begin



AddedBy := Self;

AddMethod('function MyFunc(s: String; i: Integer): Boolean',

CallMethod, 'My functions', 'The MyFunc function always returns True');

AddMethod('procedure MyProc(s: String)', CallMethod, 'My functions',

'The MyProc procedure does not do anything'');

AddedBy := nil ;


end;


end;

destructor TFunctions.Destroy;

begin

if fsGlobalUnit <> nil then


fsGlobalUnit.RemoveItems(Self);

inherited;


end;

function TFunctions.CallMethod(Instance: TObject; ClassType: TClass;

const MethodName: String ; var Params: Variant): Variant;

begin

if MethodName = 'MYFUNC' then


Result := MyFunc(Params[0], Params[1])

else if MethodName = 'MYPROC' then



MyProc(Params[0]);

end;

initialization

Functions := TFunctions.Create;

finalization

Functions.Free;

end.

Comments

  • edited 8:24AM
    fsGlobalUnit doesn't use anymore.

    Try this code:

    type
    TFunctions = class(TfsRTTIModule)
    public
    constructor Create(AScript: TfsScript); override;
    end;


    { TFunctions }


    constructor TFunctions.Create(AScript: TfsScript);
    begin
    inherited Create(AScript);
    with AScript do
    begin
    AddClass(TfrxTestLabel, 'TfrxDialogControl');
    end;
    end;


    initialization
    fsRTTIModules.Add(TFunctions);

    end.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.