我只是想将Delphi 2007应用程序转换为Delphi 10.在2007版本的软件中,我使用了一个常量的TFormatSettings。由于TFormatSettings类型在两者之间的某处发生了变化,因此我遇到了以下问题: 如何定义TFormatSettings常量?我尝试了以下方法:
XML_FormatSettings : TFormatSettings = (
CurrencyString: '€';
CurrencyFormat: 3;
CurrencyDecimals: 2;
DateSeparator: '-';
TimeSeparator: ':';
ListSeparator: ';';
ShortDateFormat: 'yyyy-MM-dd';
LongDateFormat: 'dddd, d. MMMM yyyy';
TimeAMString: '';
TimePMString: '';
ShortTimeFormat: 'hh:nn:ss';
LongTimeFormat: 'hh:nn:ss';
ShortMonthNames: ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
LongMonthNames: ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'Augut', 'September', 'October', 'November', 'December');
ShortDayNames: ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
LongDayNames: ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
EraInfo: (
EraName: ''; // <= Error here
EraOffset: 0;
EraStart: 0;
EraEnd: 0;);
ThousandSeparator: ',';
DecimalSeparator: '.';
TwoDigitYearCenturyWindow: 0;
NegCurrFormat: 8;
NormalizedLocaleName: '';);
这会出现以下错误:未声明的标识符:'EraName'
我尝试了其他几种方法,但没有找到解决方案。是否有可能定义TFormatSettings的常量?在声明常量时,如何处理在记录类型中定义和使用的记录类型?
答案 0 :(得分:3)
EraInfo
是动态记录数组,无法定义常量动态记录数组。
如果不需要EraInfo
,只需省略声明:
XML_FormatSettings : TFormatSettings = (
CurrencyString: '€';
CurrencyFormat: 3;
CurrencyDecimals: 2;
DateSeparator: '-';
TimeSeparator: ':';
ListSeparator: ';';
ShortDateFormat: 'yyyy-MM-dd';
LongDateFormat: 'dddd, d. MMMM yyyy';
TimeAMString: '';
TimePMString: '';
ShortTimeFormat: 'hh:nn:ss';
LongTimeFormat: 'hh:nn:ss';
ShortMonthNames: ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
LongMonthNames: ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'Augut', 'September', 'October', 'November', 'December');
ShortDayNames: ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
LongDayNames: ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
ThousandSeparator: ',';
DecimalSeparator: '.';
TwoDigitYearCenturyWindow: 0;
NegCurrFormat: 8;
NormalizedLocaleName: '');
省略的字段将为零或零,具体取决于其类型。