Recent

Author Topic: [SOLVED] LazReport and using scripts  (Read 3197 times)

madref

  • Hero Member
  • *****
  • Posts: 688
  • ..... A day not Laughed is a day not Lived !!
    • Nursing With Humour
[SOLVED] LazReport and using scripts
« on: July 01, 2015, 07:55:35 pm »
I am using the following script-code to determine if a distance is further than 150 km or not.
This works fine, but the outcome is a currency (euro's).
Code: [Select]
if [TQ_Rapport."IJS_Kilometers"]>=150 then
Text := [TQ_Rapport."IJS_Parkeren"]+ 7,5
else
Text := [TQ_Rapport."IJS_Parkeren"];
I would like to format this so that it has 2 decimals (8,50 instead of 8,5).
In LazReport you can format a field, but this DOES NOT work for scripted fields.


Is there another solution?
« Last Edit: July 02, 2015, 10:00:50 pm by madref »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 2.0.2 / FPC 3.0.4
Lazarus Trunc / FPC 3.0.4
Mac OS X Mojave

paweld

  • Full Member
  • ***
  • Posts: 184
Re: LazReport and using scripts
« Reply #1 on: July 01, 2015, 10:39:15 pm »
Code: [Select]
if [TQ_Rapport."IJS_Kilometers"]>=150 then
Text := FormatFloat('0.00', [TQ_Rapport."IJS_Parkeren"]+ 7,5)
else
Text := FormatFloat('0.00', [TQ_Rapport."IJS_Parkeren"]);
Best regards
paweld

madref

  • Hero Member
  • *****
  • Posts: 688
  • ..... A day not Laughed is a day not Lived !!
    • Nursing With Humour
Re: LazReport and using scripts
« Reply #2 on: July 02, 2015, 05:33:19 am »
Sorry but does not work in a script
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 2.0.2 / FPC 3.0.4
Lazarus Trunc / FPC 3.0.4
Mac OS X Mojave

jesusr

  • Sr. Member
  • ****
  • Posts: 470
Re: LazReport and using scripts
« Reply #3 on: July 02, 2015, 03:26:03 pm »
What you mean with "does not work in a script"? does it show something do you expect?, it doesn't show anything?. FormatFloat is supported

My guess is that it doesn't show anything because

Code: [Select]
Text := FormatFloat('0.00', [TQ_Rapport."IJS_Parkeren"]+ 7,5)
+ 7,5 looks suspicious to me, most probably the interpreter sees this like a syntax error.  Try with 7.5.

Also most scripts would be need to be wrapped between "begin" and "end"

madref

  • Hero Member
  • *****
  • Posts: 688
  • ..... A day not Laughed is a day not Lived !!
    • Nursing With Humour
Re: LazReport and using scripts
« Reply #4 on: July 02, 2015, 10:00:37 pm »
i thought that it wouldn't work but i made a typo.
i had a space between FormatFloat and ('0.00',.....
When i did it without the space it worked like a charm.
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 2.0.2 / FPC 3.0.4
Lazarus Trunc / FPC 3.0.4
Mac OS X Mojave