Set and receive variable
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:
fr3 code:
In theory after PrepareReport in ShowMessage I should see value 100, but it is still 10.
Thanks in advance
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
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