Delphi decimal separator issue

Viewed 13481

My application works on system with regional settings where decimal separator is comma. (Delphi 10.1)

I have set dot as decimal separator for my application .

  Application.UpdateFormatSettings := false;
  FormatSettings.DecimalSeparator := '.';
  Application.UpdateFormatSettings := true;

This works fine for me.

I have used format('%6.3f', 125.365]) function. Exe is on for 24*7 on the system..

In the initial phase like 1 or 2 hours format function returns data properly with dot as decimal separator but later on it changes to local settings comma

say 12,365.

How does dot changes to comma suddenly?

3 Answers

get the local format setting and change it.

var
  fs:TFormatSettings;
begin
    fs:=TFormatSettings.Create(GetThreadLocale());
    GetLocaleFormatSettings(GetThreadLocale(),fs);
    fs.DecimalSeparator:='.';
end
Related