... Decimal separator here is comma, but sometimes I need to format numbers from (or to) dot decimal separator. I usually have (global
) variable, set up early (in .lpr) and then just use when I need specific format.
That can hurt you.
Windows can send a message that local settings have changed, and your application (on Windows) will reset the global DefaultFormatSettings to whatever Windows says it is now.
So, if at start you change DefaultFormatSettings.DecimalSeparator to '.' (dot) and use that (DefaultFormatSetting.Decimalseparator) throughout your program, at some point it'll be reverted to ',' (comma) and your conversions wil either fail (if you use Val or TryStrToFloat) or raise an exception (if you use StrToFloat).
It's not a theoretical problem. In the past I had an application crash upon a user with a message like "1.23 is not a valid floating point value".
That baffled me for a long time, since at program start I would set DecimalSeparator to '.' (dot).
(Note: this was before the overloads with TFormatSettings were introduced in Delphi, so changing global DecimalSeparator was the only thing one could do.)
(And yes: you can fix that by telling your program to ignore this particular Windows message: Application.UpdateFormatSettings := False)
Bart