E2003 Undeclared identifier 'ShortDateFormat' error in Delphi XE3 or later versions
E2003 Undeclared identifier 'ShortDateFormat' error in Delphi XE3 or later versions
When we upgrade a Delphi old version application to Delphi XE3 or latest one then if we have used 'ShortDateFormat' global variable in our project then we will get 'E2003 Undeclared identifier 'ShortDateFormat' compiler error.
Why we get this error?
As some global variables typically pertain to Date, Time and Currency format (CurrencyString, ShorDateFormat, LongTimeFormat, ShortMonthNames, and so on) have been deprecated and removed declaration from Delphi XE3 or later versions. In old Delphi versions we can find this variables declaration in 'System.SysUtils' unit but from Delphi XE3 those are moved with TFormatSettings Record.
Workarounds to solve this error.
We can replace 'ShortDateFormat' with 'Formatsettings.ShortDateFormat'. And 'FormatSettings' is a global variable of 'TFormatSettings' type declared in 'SysUtils' which having these variables.
Errors when we migrate a project from Delphi 7 to Delphi XE3
Undeclared identifier DecimalSeparator
Undeclared identifier CurrencyFormat
Undeclared identifier ThousandSeparator
Undeclared identifier DateSeparator
Undeclared identifier TimeSeparator
Undeclared identifier ShortDateFormat
Undeclared identifier LongDateFormat
Solution to above errors
Formatsettings.DecimalSeparator
Formatsettings.CurrencyFormat
Formatsettings.ThousandSeparator
Formatsettings.DateSeparator
Formatsettings.TimeSeparator
Formatsettings.ShortDateFormat
Formatsettings.LongDateFormat
Following are some other global variables also having same issue:
Errors when we migrate a project from Delphi 7 to Delphi XE3
Undeclared identifier DecimalSeparator
Undeclared identifier CurrencyFormat
Undeclared identifier ThousandSeparator
Undeclared identifier DateSeparator
Undeclared identifier TimeSeparator
Undeclared identifier ShortDateFormat
Undeclared identifier LongDateFormat
Solution to above errors
Formatsettings.DecimalSeparator
Formatsettings.CurrencyFormat
Formatsettings.ThousandSeparator
Formatsettings.DateSeparator
Formatsettings.TimeSeparator
Formatsettings.ShortDateFormat
Formatsettings.LongDateFormat
Following are some other global variables also having same issue:
Global Variable (System.SysUtils) | Corresponding TFormatSettings Field |
---|---|
CurrencyDecimals
| |
CurrencyFormat
| |
CurrencyString
| |
DateSeparator
| |
DecimalSeparator
| |
ListSeparator
| |
LongDateFormat
| |
LongDayNames
| |
LongDayNames
| |
LongTimeFormat
| |
NegCurrFormat
| |
ShortDateFormat
| |
ShortDayNames
| |
ShortMonthNames
| |
ShortTimeFormat
| |
ThousandSeparator
| |
TimeAMString
| |
TimePMString
| |
TimeSeparator
| |
TwoDigitYearCenturyWindow
|
Comments
Post a Comment