Download FastReport 4 User`s Manual

Transcript
Script
6.3
80
"Hello, World!" script
We have already seen an example of a “Hello, World!” report; now let's see how to create a
simple script which displays a window with the same greeting.
Open the designer and click on the “New report” button so that FastReport automatically
creates a basic template. Switch to the “Code” tab and write the following script:
PascalScript:
begin
ShowMessage('Hello, World!');
end.
C++ Script:
{
ShowMessage("Hello, World!");
}
After that run the report. As expected, FastReport displays a little dialogue with a greeting:
Let's explain some details. We created a script consisting of a single “begin..end” block. So our
script has a very simple structure; it consists only of a main procedure (see the “Structure of a
script” section above). The main procedure is executed as soon as the report runs. In this case
it displayed a greeting dialogue; the procedure ends right after the dialogue is closed. After the
main procedure has finished running, the normal report construction begins.
6.4
Using objects in the script
Any report object can be accessed from a script. So, if there are for example the “Page1” page
and a “Memo1” object, they can be used in the script, calling them by their names:
PascalScript:
Memo1.Color := clRed
C++Script:
Memo1.Color = clRed
FastReport v4 © 1998-2012 FastReports Inc.
Manual v1.2.0