13

I need to find DecimalSeparator var SysUtils Delphi 7, in Delphi XE6 i tried to find in System.SysUtils, but without success. Someone can tell me where to find her in Delphi XE6?

In Delphi 7 it is located in SysUtils.pas unit, in line 618:

var 
   CurrencyString: string; 
   CurrencyFormat: Byte; 
   NegCurrFormat: Byte; 
   ThousandSeparator: Char; 
   DecimalSeparator: Char;

I need this variable to convert a component of Delphi 7 to XE6

Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
Linces Marques
  • 644
  • 1
  • 10
  • 24

2 Answers2

26

My bad, first I needed to call FormatSettings, and then I can use in DecimalSeparator in Delphi XE6,

FormatSettings.DecimalSeparator
Fabrizio
  • 7,603
  • 6
  • 44
  • 104
Linces Marques
  • 644
  • 1
  • 10
  • 24
  • 6
    The global formatting variables were deprecated in XE and were finally [removed in XE6](http://docwiki.embarcadero.com/RADStudio/XE6/en/Global_Variables). – Remy Lebeau Aug 04 '14 at 04:26
  • 1
    A global variable FormatSettings exists, along with all the problems that you can expect from a global variable. Keep this as a rule of thumb: as soon as you *write* to `FormatSettings`, you're probably doing something wrong. – Wouter van Nifterick Aug 04 '14 at 06:50
  • @Wouter van Nifterick. I'm agree that formatSetting is not the best state of art. Then what is your solution ? what is the best State of Art to not use FormatSetting ? – ffert2907 Apr 29 '19 at 17:06
  • @ffert2907: do not use the global variable, but populate a local instance of TFormatSettings, and pass that on explicitly. The global one should've never been created by Borland in the first place, because any function can change it at any time.. If you _change_ it, who know what you're affecting, or if you _use_ it, who knows that messed with it. So just avoid it whenever you can... – Wouter van Nifterick Apr 29 '19 at 19:12
7
procedure ConfigureBrazilRegion;
var
  FormatBr: TFormatSettings;
begin
  // Create new setting and configure for the brazillian format
  FormatBr                     := TFormatSettings.Create;
  FormatBr.DecimalSeparator    := ',';
  FormatBr.ThousandSeparator   := '.';
  FormatBr.CurrencyDecimals    := 2;
  FormatBr.DateSeparator       := '/';
  FormatBr.ShortDateFormat     := 'dd/mm/yyyy';
  FormatBr.LongDateFormat      := 'dd/mm/yyyy';
  FormatBr.TimeSeparator       := ':';
  FormatBr.TimeAMString        := 'AM';
  FormatBr.TimePMString        := 'PM';
  FormatBr.ShortTimeFormat     := 'hh:nn';
  FormatBr.LongTimeFormat      := 'hh:nn:ss';
  FormatBr.CurrencyString      := 'R$';

  // Assign the App region settings to the newly created format
  System.SysUtils.FormatSettings := WFormatBr;
end;
Rod Lima
  • 1,509
  • 26
  • 30
  • 3
    @user30478 the description is the question, just read it first and comment if you still have any doubts. – Rod Lima Jun 21 '18 at 13:57
  • Thanks. This is a code from kazip 2.0 demo. It uses this separator like - TS := SysUtils.ThousandSeparator; Try SysUtils.ThousandSeparator := ' '; ... finally.. SysUtils.ThousandSeparator := TS; end; don't know how to make this D7 code work for DXE5. – user30478 Jun 21 '18 at 14:58
  • Hey @user30478, look at the code again. Hope you understand with comments. This code works with DXE5. – Rod Lima Jun 22 '18 at 14:53