如何定义 TFormatSettings 常量 (Delphi 10)

How to define a TFormatSettings constant (Delphi 10)

我只是想将 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 常量?声明常量时如何处理在记录类型中定义和使用的记录类型?

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:      '');

省略的字段将是零或零,具体取决于它们的类型。