In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Bug with variables

FastReport for Xailer & [x]Harbour (English/Spanish)
dmajkic
Posts: 23
Joined: Wed Sep 24, 2014 12:48 pm

Bug with variables

Postby dmajkic » Tue Apr 14, 2020 10:41 pm

We are using one variable as coefficient for some calculations. We are encountering a bug if number has decimals.

On HB side we have this:

Code: Select all

nBol := 0.65
oFR:AddVariable("_BOL", nBol)

on FR side, we have this:

Code: Select all

[<SomeField>*<_BOL>]


The issue is that variables in FR are exclusively strings. And our 0.65 gets converted to 0,65 (if locale uses coma as decimal separator)
And then expresion on FR side raises exception, as it expects US/Pascal numbers (with decimal point) in field expresions
If we format 0.65 to string, and call AddVariable() -> FRX wil add quotes: '0.65' and that also will not work in expresions.

We need a way to format our own string and send it to FR without quotes.

Is there any way we could do this?
User avatar
ignacio
Site Admin
Posts: 8656
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: Bug with variables

Postby ignacio » Wed Apr 15, 2020 8:53 pm

Hello,

FRX can add variables as numbers. Try this:

[<_BOL>+10]

It should print 10.65

Regards
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
dmajkic
Posts: 23
Joined: Wed Sep 24, 2014 12:48 pm

Re: Bug with variables

Postby dmajkic » Fri Apr 17, 2020 9:38 am

FRX can add variables as numbers. Try this:


This will not work. If windows locale is set to Serbian Latin, where numbers are formated as 123,00

_BOL gets converted to 0,65 (note the coma), and expresion is [0,65+10] which raises exception.

If we format _BOL as string :AddVariable("_BOL", "0.65") FRX will add quotes, and our expression is ['0.65' + 10] which also raises exception.

We solved it by inheriting FastReport class, add calling :SetCargo(STR(_BOL)), :AddVariableC("_BOL"),
wich works as expected - we have [0.65 + 10] regardless of system locale.
User avatar
ignacio
Site Admin
Posts: 8656
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Re: Bug with variables

Postby ignacio » Fri Apr 17, 2020 10:40 am

Hi,

This will not work. If windows locale is set to Serbian Latin, where numbers are formated as 123,00


Is the same case in Spanish and here is working fine. :shock:

If we format _BOL as string :AddVariable("_BOL", "0.65") FRX will add quotes, and our expression is ['0.65' + 10] which also raises exception.


Logical. On that case you could use the FR function StringToFloat() (or something similar)

We solved it by inheriting FastReport class, add calling :SetCargo(STR(_BOL)), :AddVariableC("_BOL"),
wich works as expected - we have [0.65 + 10] regardless of system locale.


Glad you solve it. Thank you for the feedback.

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
http://www.xailer.com
nbatocanin
Posts: 26
Joined: Sat Aug 10, 2013 2:39 am

Re: Bug with variables

Postby nbatocanin » Thu Apr 30, 2020 3:25 am

This only partially solved the problem, I think there is a bug in FR. Would it help to make one simple example with this error?

NB

Return to “FastReport”