Primeri uporabe objektov v skriptah
Let's take a look at two examples of using report objects in the script.
Highlighting Every Second Row Line
Sometimes, in order to achieve greater transparency, we want each other line to appear with a different background color.
Let's take a look at an example of script hat is defined to the item ID in order to appear in yellow on each second line. As a basis, we will use report '147 - Current Stock by Warehouses and Items', that is in the program menu 'Goods |Stock report | Current stock'. We replace script in the "DetailOnBeforePrint" event with the following:
procedure DetailOnBeforePrint(Sender: TfrxComponent);
begin
if <Line#> mod 2 = 0 then
fIdent.Color := clYellow
else
fIdent.Color := clNone;
end;
Value of Color property 'clNone' means transparent color.
Conditional Changing Font Style
Let's take a look at an example of a program code, which is already on report '051 - Financial Report', that is in the program menu 'Financials |Reports | Financial Reports'. On the financial reports is a field "acBold" which defines whether data on report will be displayed with bold font. Script on the report is the following:
procedure fNazivOnBeforePrint(Sender: TfrxComponent);
begin
if <qReportIzpis."acBold"> = 'T' then
begin
fNaziv.Font.Style := fsBold;
fVrednost1.Font.Style := fsBold;
fVrednost2.Font.Style := fsBold;
end
else
begin
fNaziv.Font.Style := 0;
fVrednost1.Font.Style := 0;
fVrednost2.Font.Style := 0;
end;
end;
The value of the font style 0 means that no style is selected. If we want to set bold and italic font we write for example:
fNaziv.Font.Style := fsBold + fsItalic;