New objects can be added to a report using a script. Let's show how this is done with a simple example. Create a blank report and enter this code in the script’s main procedure:
PascalScript:
var
Band: TfrxReportTitle;
Memo: TfrxMemoView;
begin
Band := TfrxReportTitle.Create(Page1);
Band.Height := 20;
Memo := TfrxMemoView.Create(Band);
Memo.SetBounds(10, 0, 100, 20);
Memo.Text := 'This memo is created in code';
end.
C++ Script:
TfrxReportTitle Band;
TfrxMemoView Memo;
{
Band = TfrxReportTitle.Create(Page1);
Band.Height = 20;
Memo = TfrxMemoView.Create(Band);
Memo.SetBounds(10, 0, 100, 20);
Memo.Text = "This memo is created in code";
}
Preview the report:
Note that we did not destroy the FastReport objects we created in this example. This is not required as FastReport objects are automatically destroyed by the Delphi application after the report is completed. Also note that when we create standard Delphi objects in a script (such as TStringLists) we also have to destroy them in the script, as this will not be done automatically by the application.
|