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 5:19PM
    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

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.