the "uses" statement

edited April 2015 in FastReport 4.0
I have a module called "UnitConversion.pas", that contains an object called TUnitProperties.

for example:
TUnitProperties = class(TPersistent)
private
FPowerUnits: byte;
FPowerDecimals: byte;
protected
{}
published
constructor Create;
destructor destroy;
procedure CopyUnitPropertiesFrom(aValue: TUnitProperties);
public
Property PowerUnits: byte read FPowerUnits write FPowerUnits;
Property PowerDecimals: byte read FPowerDecimals write FPowerDecimals;
end;

On my fxReport1 code page, I have declared the following

uses 'UnitConversion.pas';

var FUnitProperties: TUnitProperties;

//main
begin
{}
end

when I try to preview the report, I get an error, "identifier expected". what's happening, and how do i make the module UnitConversion visible in fxReport1??

TIA,
Arthur

Comments

  • edited 7:13PM
    If you want to call any procs defined by Delphi code from FastReport,
    you must register procs into FastReport.

    for example:
    function TMainForm.SomeFunc(AParam: Integer): Integer;
    begin
      Result := AParam * 10;
    end;
    
    //OnUserFunction event of frxReport component
    function TMainForm.frxReport1UserFunction(const MethodName: string;
      var Params: Variant): Variant;
    begin
      if MethodName = 'SOMEFUNC' then
        Result := SomeFunc(Params[0]);
    end;
    
    constructor TMainForm.Create(AOwner: TComponent);
    begin
      inherited;
    
      //add custom function to the report
      frxReport1.AddFunction('function SomeFunc(AParam: Integer): Integer');
    end;
    

    then you are able to call 'SomeFunc' from FastReport code without 'uses' clause.

Leave a Comment