Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: CurrencyFormat - Worked in D2006, not working in XE8 - what's different?


This question is answered.


Permlink Replies: 2 - Last Post: May 26, 2015 4:52 PM Last Post By: Carl Olsen Threads: [ Previous | Next ]
Carl Olsen

Posts: 124
Registered: 3/29/00
CurrencyFormat - Worked in D2006, not working in XE8 - what's different?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 26, 2015 3:46 PM
I have the following code that used to work in Delphi 2006:

  Case CurrencyFormat of
    0: Result:=CurrencyString+InNumber;
    1: Result:=InNumber+CurrencyString;
    2: Result:=CurrencyString+' '+InNumber;
    3: Result:=InNumber+' '+CurrencyString;
    else Result:=CurrencyString+': '+InNumber;
  end;


In XE8, I get the errors,

E2003 Undeclared identifier: 'CurrencyFormat'
E2003 Undeclared identifier: 'CurrencyString'

What do I need to do differently?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: CurrencyFormat - Worked in D2006, not working in XE8 - what'sdifferent?
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 26, 2015 4:49 PM   in response to: Carl Olsen in response to: Carl Olsen
Carl wrote:

In XE8, I get the errors,

E2003 Undeclared identifier: 'CurrencyFormat'
E2003 Undeclared identifier: 'CurrencyString'

What do I need to do differently?

The global formatting variables were deprecated in XE and removed in XE3:

http://docwiki.embarcadero.com/RADStudio/XE3/en/Global_Variables

Twenty global variables that previously resided in System.SysUtils, and which
have been deprecated for several years, have now been removed from the product.
These global variables typically pertain to date, time, and currency format
(CurrencyString, LongTimeFormat, ShortMonthNames, and so on).

You need to use the TFormatSettings record now, which was introduced way
back in Delphi 7:

var
  Fmt: TFormatSettings;
 
{$IF RTLVersion >= 23} // XE2+
Fmt := TFormatSettings.Create;
{$ELSE}
GetLocaleFormatSettings(0, Fmt);
{$ENDIF}
 
Case Fmt.CurrencyFormat of
  0: Result := Fmt.CurrencyString + InNumber;
  1: Result := InNumber + Fmt.CurrencyString;
  2: Result := Fmt.CurrencyString + ' ' + InNumber;
  3: Result := InNumber + ' ' + Fmt.CurrencyString;
  else Result := Fmt.CurrencyString + ': ' + InNumber;
end;


--
Remy Lebeau (TeamB)
Carl Olsen

Posts: 124
Registered: 3/29/00
Re: CurrencyFormat - Worked in D2006, not working in XE8 - what'sdifferent?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 26, 2015 4:52 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thank you Remy! That is exactly the information I was looking for!

Edited by: Carl Olsen on May 26, 2015 4:52 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02