Recent

Author Topic: Question about fpreport  (Read 600 times)

ginoo

  • Full Member
  • ***
  • Posts: 160
Question about fpreport
« on: March 04, 2026, 12:20:14 pm »
I ran some tests and found that the OnBeforePrint event is misaligned with the dataset it refers to. For example,

OnBeforePrint
I read the value of HotelDataSet -> ID and write it to a memo; the value is printed in the next step.

Now the question: if I want to read a value from HotelDataSet and change a color based on it, how should I do it?

Thank you

Graeme

  • Hero Member
  • *****
  • Posts: 1518
    • Graeme on the web
Re: Question about fpreport
« Reply #1 on: March 05, 2026, 01:46:07 am »
See the `rptexpressions.pp` demo included with fcl-report (part of FPC's source code). It's the expression evaluator demo report.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

ginoo

  • Full Member
  • ***
  • Posts: 160
Re: Question about fpreport
« Reply #2 on: March 05, 2026, 06:31:46 am »
Thanks @Graeme for reporting it. I looked at the example and I'm looking at it again now, but I don't think it helps, so I'll explain why.
In the OnBeforePrint event, whether I use values ​​from a dataset or a variable, they're assigned to the next line.

To illustrate with the example you provided, in `rptexpressions.pp` after the first TExpressionsDemo.DoBeforePrint, the value of rpt.Variables.FindVariable('isEven').AsBoolean is "false," but the first line of the report displays "true." This is because, as mentioned above, the next line is displayed.

Another problem is that zeos calculated fields don't work; I didn't recognize them.

ginoo

  • Full Member
  • ***
  • Posts: 160
Re: Question about fpreport
« Reply #3 on: March 05, 2026, 07:17:44 am »
I'm no expert, but at first glance, an event should be added to
the TFPReportLayouter.ShowDetailBands procedure; on line 11986.

 

TinyPortal © 2005-2018