Recent

Author Topic: strtofloatdef?  (Read 2832 times)

Robz

  • New Member
  • *
  • Posts: 38
strtofloatdef?
« on: March 25, 2018, 06:30:35 am »
How do I use strtofloatdef?
Something changed, the function previously was simple.
strtofloatdef(s: string, default: extended; format: string): extended;
where format, example: '##.00'
I get an error if I use this string format; expecting TFormatSettings.
What is TFormatSettings and how do I get the format equivalent of '#.00'?
Why the added complexity, it was previously simple to use.
Has quantum physics changed history?

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: strtofloatdef?
« Reply #1 on: March 25, 2018, 08:59:04 am »
It seems you're using ancient version of the compiler. What is the version of your Lazarus/FPC?

Information of StrToFloat and TFormatSetting can be found here:
https://www.freepascal.org/docs-html/rtl/sysutils/strtofloat.html
https://www.freepascal.org/docs-html/rtl/sysutils/tformatsettings.html

Example how to use TFormatSetting:
http://forum.lazarus.freepascal.org/index.php/topic,39854.msg275307.html#msg275307

balazsszekely

  • Guest
Re: strtofloatdef?
« Reply #2 on: March 25, 2018, 09:01:36 am »
@Robz
Quote
How do I use strtofloatdef?
Something changed, the function previously was simple.
strtofloatdef(s: string, default: extended; format: string): extended;
where format, example: '##.00'
I get an error if I use this string format; expecting TFormatSettings.
What is TFormatSettings and how do I get the format equivalent of '#.00'?
Why the added complexity, it was previously simple to use.
Has quantum physics changed history?
Actually both version of StrToFloadDef exists in a superposition(see attachment). When you made a measurement you collapsed the wave function.  :D

TFormatSettings: https://www.freepascal.org/docs-html/rtl/sysutils/tformatsettings.html
« Last Edit: March 25, 2018, 09:49:08 am by GetMem »

Robz

  • New Member
  • *
  • Posts: 38
Re: strtofloatdef?
« Reply #3 on: March 26, 2018, 03:23:31 am »
It seems you're using ancient version of the compiler. What is the version of your Lazarus/FPC?

Handoko, thank you for your reply. I am using Version 1.6.2 with FPC 3.0.0. However, I believe my question must be better defined. Thinking about the requirement, formatting should be applied to a string. I will probably get a pointless result converting a formatted text number to a double floating point number.
Thanks again, Robert


 

TinyPortal © 2005-2018