[Lazarus] Lazreport variables
Santiago A.
svaa at ciberpiula.net
Mon May 11 20:43:02 CEST 2020
El 11/05/2020 a las 16:12, Graeme Geldenhuys via lazarus escribió:
> On 03/05/2020 5:03 pm, Santiago A. via lazarus wrote:
>> I want to write a report where even lines are written with no background
>> and odd lines with a light gray background.
> Have you considered using the newer FPReport (aka fcl-report) included
> with FPC? There is a report designer for Lazarus too. It is super simple
> to implement the alternating colors that you required. Take a look at
> the fcl-report/demos/ directory and look at the "rptexpressions.pas"
> unit. All you need to do is assign the alternating colors in the
> DoBeforePrint() event handler.
>
> eg:
>
> procedure TExpressionsDemo.DoBeforePrint(Sender: TFPReportElement);
> begin
> With rpt.Variables.FindVariable('isEven') do
> AsBoolean:=Not AsBoolean;
> if rpt.Variables.FindVariable('isEven').AsBoolean then
> Sender.Frame.BackgroundColor := clLtGray
> else
> Sender.Frame.BackgroundColor := clWhite;
> end;
>
>
>
> Regards,
> Graeme
>
Yes, in fact I have solved it with a similar way using events in pascal.
Nevertheless, that is not the question. Do variables work in LazReport
or not? if they do, how?
I have hidden a band and a few tweaks using the reports scripts, that
means that I have divided the logic of the report in the scripts in lrf
file and in events in the pascal source. If I can't trust that scripts
work, I will move everything to pascal and let the report just for
basic graphic design with no script.
Using only pascal events is not the best solution, because I could, for
example, change the design of alternate colors of the band to a line
division without touching the pascal code and having to generate a new
executable.
I still hope that I have misunderstood something about variables, or at
least it is known bug.
--
Saludos
Santiago A.
More information about the lazarus
mailing list