Scripting error

edited February 2015 in FastReport VCL 5
Using FastReport VCL v5.1.5 and Delphi XE6:

I have an exisiting report FastReport that previews successfully.

When I add the code below to the beginning of the report's Code tab I get a "';' expected" error when previewing the report in the designer and my Delphi application (<NumPrinted> is a Report variable).
Var
NewCopies : integer;

procedure frxReportOnReportPrint(Sender: TfrxComponent);
begin
NewCopies := frxReport.PrintOptions.Copies;
<NumPrinted> := <NumPrinted> + NewCopies;
end;
If I comment out both lines of code in the procedure I get no error;
If I comment out the first line only I still get the "';' expected" error. (I can't see a missing [img]style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> If I comment out the second line only I get an "Undeclared identifier: 'frxReport'" error. (The procedure name[/img]is frxReport..... )

How do I correct the code ?
My intention is to send back to my Delphi application the number of copies actually printed from the report preview window.

Comments

  • edited 7:48PM
    hi

    what kind of variable is "<NumPrinted>"? i.e. system, report, external, if it's a report variable, probably you should initialize the value of variable, zero for example, maybe the current value of your variable is null, in that case, when you preview the report generate that kind of error

    regards
  • gpigpi
    edited 7:48PM
        Var
        NewCopies : integer;
    
    procedure frxReportOnReportPrint(Sender: TfrxComponent);
    begin
      NewCopies := Report.PrintOptions.Copies;
      Set('NumPrinted', <NumPrinted> + NewCopies);
    end;
    
    begin
         Report.EngineOptions.DestroyForms := False;                                                                                        
    end.
    
  • edited 7:48PM
    Thanks to both respondees - gpi's code works as I intended it.

    It's rather counter-intuitive though : the FR-Object Inspector contains 'frxReport: TfrxReport' and all the procedures are named 'frxReport...' - so why do you have to use 'Report.PrintOptions..' instead of 'frxReport.PrintOptions.. ?

    It's also not obvious that you have to use
    'Report.EngineOptions.DestroyForms := False;'
    to be able to read back the changed report variable <NumPrinted> after preview and printing.

    Many thanks.
  • gpigpi
    edited 7:48PM
    wrote:
    the FR-Object Inspector contains 'frxReport: TfrxReport' and all the procedures are named 'frxReport...'
    See Report tree
    wrote:
    It's also not obvious that you have to use
    'Report.EngineOptions.DestroyForms := False;'
    to be able to read back the changed report variable <NumPrinted> after preview and printing.
    This code needs to execute frxReportOnReportPrint after preparing of report

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.