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)
Responder
dmajkic
Mensajes: 23
Registrado: Mié Sep 24, 2014 12:48 pm

Bug with variables

Mensaje por dmajkic »

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:

Código: Seleccionar todo

nBol := 0.65
oFR:AddVariable("_BOL", nBol)
on FR side, we have this:

Código: Seleccionar todo

[<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?
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9246
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: Bug with variables

Mensaje por ignacio »

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]
https://www.xailer.com
dmajkic
Mensajes: 23
Registrado: Mié Sep 24, 2014 12:48 pm

Re: Bug with variables

Mensaje por dmajkic »

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.
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9246
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: Bug with variables

Mensaje por ignacio »

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]
https://www.xailer.com
nbatocanin
Mensajes: 42
Registrado: Sab Ago 10, 2013 2:39 am

Re: Bug with variables

Mensaje por nbatocanin »

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
Responder