Re: [Lazarus] Lazreport variables

2020-05-11 Thread Santiago A. via lazarus

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.

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Lazreport variables

2020-05-11 Thread Graeme Geldenhuys via lazarus
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

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Lazreport variables

2020-05-07 Thread Лагунов Алексей via lazarus
Define variable in report header bandОтправлено из мобильной Яндекс.Почты: http://m.ya.ru/ymail11:09, 7 мая 2020 г., "Santiago A. via lazarus" :
El 07/05/2020 a las 05:37, Jesus Reyes
  A. via lazarus escribió:


  
  
  En Sun, 03 May 2020 11:03:12 -0500, Santiago A. via lazarus
   escribió:
  
   Hi:

I want to write a report where even lines are written with no
background and odd lines with a light gray background.
The idea is an memo (MemoBackground) in the background of the
masterData Band that is gray and I set visible or invisible,
according with the line.

I have created a report variable "LineCounter"

In the ColumnHeader band (the report has two columns) I have a
Script
Begin
 LineCounter:=0;
end;
In the GorupHeader header I have this script
Begin
 LineCounter:=0;
end;
In the masterData band Script:
begin
 LineCounter:=LineCounter+1;
 MemoBackground.visible:=(LineCounter mod 2 = 0);
end
   
  
  
  Probably the easiest way of doing what you want is using an
empty memo object sized to the extent you want for the
background row, any other field on the band should be 'above'
the background memo (you can just select the background memo and
press the 'send to bottom' tool button), any field on the band
should be transparent color. Then edit the background memo and
use this script:
  
  
  if [LINE#] mod 2 = 0 then
    FillColor := clGray
else
    FillColor := clWhite;  
  
  
  As written and because the variable Line# starts at 1, the
first line will be white.
  
  
  You can apply this method to any existing report as it
doesn't require modifying the source code of your application. 
  
  
  Regards.
  
  
  Jesus Reyes A.
  
  


Ok I'll try
Nevertheless, that doesn't answer my question: How to use
"not-predefined" variables. How can I access to the variable
lineCounter?


-- 
Saludos

Santiago A.

  
-- ___lazarus mailing listlazarus@lists.lazarus-ide.orghttps://lists.lazarus-ide.org/listinfo/lazarus
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Lazreport variables

2020-05-07 Thread Santiago A. via lazarus

El 07/05/2020 a las 05:37, Jesus Reyes A. via lazarus escribió:
En Sun, 03 May 2020 11:03:12 -0500, Santiago A. via lazarus 
 escribió:


Hi:

I want to write a report where even lines are written with no
background and odd lines with a light gray background.
The idea is an memo (MemoBackground) in the background of the
masterData Band that is gray and I set visible or invisible,
according with the line.

I have created a report variable "LineCounter"

In the ColumnHeader band (the report has two columns) I have a Script

Begin
  LineCounter:=0;
end;

In the GorupHeader header I have this script

Begin
  LineCounter:=0;
end;

In the masterData band Script:

begin
  LineCounter:=LineCounter+1;
  MemoBackground.visible:=(LineCounter mod 2 = 0);
end


Probably the easiest way of doing what you want is using an empty memo 
object sized to the extent you want for the background row, any other 
field on the band should be 'above' the background memo (you can just 
select the background memo and press the 'send to bottom' tool 
button), any field on the band should be transparent color. Then edit 
the background memo and use this script:


if [LINE#] mod 2 = 0 then
  FillColor := clGray
else
  FillColor := clWhite;

As written and because the variable Line# starts at 1, the first line 
will be white.


You can apply this method to any existing report as it doesn't require 
modifying the source code of your application.


Regards.

Jesus Reyes A.



Ok I'll try
Nevertheless, that doesn't answer my question: How to use 
"not-predefined" variables. How can I access to the variable lineCounter?



--
Saludos

Santiago A.

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Lazreport variables

2020-05-06 Thread Jesus Reyes A. via lazarus
En Sun, 03 May 2020 11:03:12 -0500, Santiago A. via lazarus  
 escribió:



Hi:

I want to write a report where even lines are written with no background  
and odd lines with a light >gray background.
The idea is an memo (MemoBackground) in the background of the masterData  
Band that is gray and I >set visible or invisible, according with the  
line.


I have created a report variable "LineCounter"

In the ColumnHeader band (the report has two columns) I have a Script
Begin
LineCounter:=0;
end;
In the GorupHeader header I have this script
Begin
LineCounter:=0;
end;
In the masterData band Script:
begin
LineCounter:=LineCounter+1;
MemoBackground.visible:=(LineCounter mod 2 = 0);
end



Probably the easiest way of doing what you want is using an empty memo  
object sized to the extent you want for the background row, any other  
field on the band should be 'above' the background memo (you can just  
select the background memo and press the 'send to bottom' tool button),  
any field on the band should be transparent color. Then edit the  
background memo and use this script:


if [LINE#] mod 2 = 0 then
  FillColor := clGray
else
  FillColor := clWhite;

As written and because the variable Line# starts at 1, the first line will  
be white.


You can apply this method to any existing report as it doesn't require  
modifying the source code of your application.


Regards.

Jesus Reyes A.-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Lazreport variables

2020-05-03 Thread Bart via lazarus
On Sun, May 3, 2020 at 7:33 PM Santiago A. via lazarus
 wrote:

> TStringGrid? It is a report using LazReport, What has TSringGrid to do
> with LazReport?

I have no experience with LazReport.
You wrote you would make the report in a memo, I assumed you could do
that in a TSTringGrid as well.
It seems, you can not?

> What is OI?
The Object Inspector.


-- 
Bart
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Lazreport variables

2020-05-03 Thread Santiago A. via lazarus

El 03/05/2020 a las 18:04, Bart via lazarus escribió:

On Sun, May 3, 2020 at 6: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.

A little bit out of the box thinking :-)

You could add the lines to a TStringGrid (ColCount := 1) and set the
color for the alternating row in OI.


Sorry I haven't understand anything ;-)

TStringGrid? It is a report using LazReport, What has TSringGrid to do 
with LazReport?

What is OI?

--
Saludos

Santiago A.

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Lazreport variables

2020-05-03 Thread Bart via lazarus
On Sun, May 3, 2020 at 6: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.

A little bit out of the box thinking :-)

You could add the lines to a TStringGrid (ColCount := 1) and set the
color for the alternating row in OI.

-- 
Bart
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Lazreport variables

2020-05-03 Thread Santiago A. via lazarus

Hi:

I want to write a report where even lines are written with no background 
and odd lines with a light gray background.
The idea is an memo (MemoBackground) in the background of the masterData 
Band that is gray and I set visible or invisible, according with the line.


I have created a report variable "LineCounter"

In the ColumnHeader band (the report has two columns) I have a Script

Begin
 LineCounter:=0;
end;

In the GorupHeader header I have this script

Begin
 LineCounter:=0;
end;

In the masterData band Script:

begin
 LineCounter:=LineCounter+1;
 MemoBackground.visible:=(LineCounter mod 2 = 0);
end

When I prepare the report, I get "Invalid Variant Type Cast"

After debugging a little, I have found LineCounter is undefined when it 
is on the right side of assignment.
When It executes  LineCounter:=0; it assigns to a frVariables, a global 
public var in Unit LR_Class.
But when it tries to get its value it searches en a field "values" of 
TfrReport.


I've also tried

LineCounter:=[LineCounter]+1;

With brackets, the same result. (Not sure what brackets are for in scripts)

Any hint? What am I missing?

--
Saludos

Santiago A.

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus