Set and receive variable

edited August 2013 in FastReport 4.0
Hi,

I looked through the internet but I didn't foud answer.

I have FastReport in 4.13.1 version.

I'm trying to create variable, then send this variable in report. Next, change variable in report script, after that I want to receive this variable with new value.
My code for now is:

delphi code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  frxReport1.Variables[' ' + 'category'] := Null;
  frxReport1.Variables.AddVariable('category', 'abc', 10);

  frxReport1.DesignReport;
  frxReport1.PrepareReport(true);
  ShowMessage( VarToStr( frxReport1.Variables['abc'] ));
  frxReport1.ShowPreparedReport;
  ShowMessage( VarToStr( frxReport1.Variables['abc'] ));
end;

fr3 code:
procedure frxReport1OnStartReport(Sender: TfrxComponent);
begin
       Set('abc', 100);           
end;

begin

end.

In theory after PrepareReport in ShowMessage I should see value 100, but it is still 10.

Thanks in advance

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 4:35PM
    you can find everything in the Programmers manual and user manual
    first are you working with a report saved as a file .fr3 or one stored in the dfm.
    if working with a file you must load the file first.
    2 clear the variable list if it was already created
    3 give your category a name other than category.
    3 block your call to the designer use it only temporarily to see what you have created.
    4 you can just call showreport instead of preparing.
    5 your last showmessage should be in the report, you can retrieve it from where you are..
    ie in an obp event showmessage(inttostr(<abc>)); or if you want to do it from delphi use the tfrxreport component's obp event
    6 move your report code into the empty begin end blockl

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.