Recent

Author Topic: calculating values in fpreport  (Read 3685 times)

MacWomble

  • Jr. Member
  • **
  • Posts: 79
calculating values in fpreport
« on: December 21, 2019, 09:33:06 am »
Does anyone know how to define sums or other calculations in fpreport designer ?  %)

There must be a way to do page sum, report sum etc. e.g. for invoices. Is this possible and how to do?
« Last Edit: December 22, 2019, 11:46:03 pm by MacWomble »
Mint 19.3 Cinnamon, FPC/ Lazarus Trunk 64Bit

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: calculating values in fpreport
« Reply #1 on: January 06, 2020, 08:21:43 pm »
I haven't used designer so far but in code it's possible: see rptnestedgroups.pp in packages/fcl-report/demos.

Add an expression variable and set the reset expression to that of the group:
Code: Pascal  [Select][+][-]
  1. rpt.Variables.AddExprVariable('grp1region_sum_population', 'sum(StrToFloat(population))', rtFloat, GroupHeader1Region);

Use it in memo:
Code: Pascal  [Select][+][-]
  1. Memo.Text := '[formatfloat(''#,##0.0'',StrToFloat(population)/grp1region_sum_population*100)] %';

This should be possible in designer, too.

laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: calculating values in fpreport
« Reply #2 on: January 06, 2020, 08:44:20 pm »
IMHO there are some features actual in the designer and you can not do the same thing like in code.

More people should try the designer and test it :-) before make a post with 'This should be possible...'. No actual it is IMHO not possible - and this was the question.
regards
Andreas

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: calculating values in fpreport
« Reply #3 on: January 06, 2020, 08:57:53 pm »
I am just investigating this topic. The appropriate functions seems to be there in "Report/Variables...".
I'll try to build a simple sample report.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: calculating values in fpreport
« Reply #4 on: January 07, 2020, 08:33:41 am »
Thank you, for your investigatement.

Please try it with designer only. 
regards
Andreas

MacWomble

  • Jr. Member
  • **
  • Posts: 79
Re: calculating values in fpreport
« Reply #5 on: January 07, 2020, 10:47:01 am »
More people should try the designer and test it :-) ...

Yeah, that would be great!

@Pascal: Great to have some help here ! Thank You !
Mint 19.3 Cinnamon, FPC/ Lazarus Trunk 64Bit

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: calculating values in fpreport
« Reply #6 on: January 07, 2020, 02:11:40 pm »
Will be a bunch of work!
Just realized that all my old samples with plenty of aggregations and grouping do not work anymore with current version.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: calculating values in fpreport
« Reply #7 on: January 07, 2020, 07:03:18 pm »
BTW. when i mean - some features - it is sarcastic. Actual i am diving back to the fpc part of fpreport and look if it is bugfree or not.
regards
Andreas

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: calculating values in fpreport
« Reply #8 on: January 07, 2020, 07:25:50 pm »
With the decision of MvC here (https://bugs.freepascal.org/view.php?id=36525) ist looks impossible to use the fpexpression in the fpreport for calculating of aggregations and grouping on an non english configured system. On a german system the decimal seperator is a comma not a dot. If data is sent to fpexpression it must be converted to a non system standard value to be aggregated. The same problem i have found in the tests of fpreport, because the Formatsettings sometimes not handled ( https://bugs.freepascal.org/view.php?id=36519 ). I think the fpreport was not well testet with other Formatsettings.

This made the things bad twice.

regards
Andreas

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: calculating values in fpreport
« Reply #9 on: January 07, 2020, 09:21:27 pm »
Never mind, i will spend some time on this. But i have to study the changes of the last two years, as my last active development on fpreport was back in 2017. So please be patient or submit patches.
I will first make the nestedgroup demo work again, as this is the most complex one.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: calculating values in fpreport
« Reply #10 on: January 07, 2020, 10:14:15 pm »
BTW: some if the tests of fpreport did not work too. Time is no problem, i will understand more of the internal working. At christmas it was possible for me to dive in a little, it is a hobby for me.
« Last Edit: January 07, 2020, 10:17:23 pm by af0815 »
regards
Andreas

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: calculating values in fpreport
« Reply #11 on: January 07, 2020, 10:20:34 pm »
With the decision of MvC here (https://bugs.freepascal.org/view.php?id=36525) ist looks impossible to use the fpexpression in the fpreport for calculating of aggregations and grouping on an non english configured system. On a german system the decimal seperator is a comma not a dot. If data is sent to fpexpression it must be converted to a non system standard value to be aggregated. The same problem i have found in the tests of fpreport, because the Formatsettings sometimes not handled
Looking in the fcl-report/src directory I found a unit fprexprpars which is more or less a copy of the standard fpexprpars unit (note the additional "r" behind the "fp"); this was probably needed to provide dedicated adjustments of the parser for the report engine which should not be used in the standard parser. Maybe MvC changes his mind when the patch of the bug report is modified to apply to fprexprpars, not to fpexprpars?

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: calculating values in fpreport
« Reply #12 on: January 08, 2020, 08:41:46 am »
With the decision of MvC here (https://bugs.freepascal.org/view.php?id=36525) ist looks impossible to use the fpexpression in the fpreport for calculating of aggregations and grouping on an non english configured system. On a german system the decimal seperator is a comma not a dot. If data is sent to fpexpression it must be converted to a non system standard value to be aggregated. The same problem i have found in the tests of fpreport, because the Formatsettings sometimes not handled
Looking in the fcl-report/src directory I found a unit fprexprpars which is more or less a copy of the standard fpexprpars unit (note the additional "r" behind the "fp"); this was probably needed to provide dedicated adjustments of the parser for the report engine which should not be used in the standard parser. Maybe MvC changes his mind when the patch of the bug report is modified to apply to fprexprpars, not to fpexprpars?

Can't find it! Did you mix it up with fprepexprpars, which is used for fpc versions below 030101?
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

MacWomble

  • Jr. Member
  • **
  • Posts: 79
Re: calculating values in fpreport
« Reply #13 on: January 08, 2020, 09:20:24 am »
fprepexprpars.pp is in my fpreport directory too ...
Mint 19.3 Cinnamon, FPC/ Lazarus Trunk 64Bit

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: calculating values in fpreport
« Reply #14 on: January 08, 2020, 09:27:26 am »
With the decision of MvC here (https://bugs.freepascal.org/view.php?id=36525) ist looks impossible to use the fpexpression in the fpreport for calculating of aggregations and grouping on an non english configured system. On a german system the decimal seperator is a comma not a dot. If data is sent to fpexpression it must be converted to a non system standard value to be aggregated. The same problem i have found in the tests of fpreport, because the Formatsettings sometimes not handled
Looking in the fcl-report/src directory I found a unit fprexprpars which is more or less a copy of the standard fpexprpars unit (note the additional "r" behind the "fp"); this was probably needed to provide dedicated adjustments of the parser for the report engine which should not be used in the standard parser. Maybe MvC changes his mind when the patch of the bug report is modified to apply to fprexprpars, not to fpexprpars?

Can't find it! Did you mix it up with fprepexprpars, which is used for fpc versions below 030101?
It is in the official sources of fpc trunk: https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/fcl-report/src/fprepexprpars.pp?view=log. If it is not needed any more it should be removed.

 

TinyPortal © 2005-2018