【问题标题】:Errors: Undeclared identifier 'DecimalSeparator' and no overloaded version of 'StringReplace' [duplicate]错误:未声明的标识符“DecimalSeparator”并且没有“StringReplace”的重载版本[重复]
【发布时间】:2015-10-12 02:12:41
【问题描述】:

您好,我一直在编码,到目前为止,在 WinXP 中的 Delphi 2007 中开发和编译直到 Win7 中的 Delphi XE7 都没有问题。

我不知道为什么会这样。

错误指向的行

....
if(tS<>'') then
begin
  Result:=StrToFloat(StringReplace(String(tS),'.',DecimalSeparator,[]));
  Invalid:=False;
end;
....

错误:

1) [dcc32 Error] UtilNumString.pas(321): E2003 Undeclared identifier:     'DecimalSeparator'
2) [dcc32 Error] UtilNumString.pas(321): E2250 There is no overloaded version     of 'StringReplace' that can be called with these arguments   

请亲建议。 谢谢

【问题讨论】:

    标签: delphi delphi-xe7


    【解决方案1】:

    格式设置的旧全局变量已被删除。您可以使用FormatSettings 全局变量:

    Result:=StrToFloat(StringReplace(String(tS),'.',FormatSettings.DecimalSeparator,[]));
    

    或者,或者(理想情况下...),您可以创建一个本地 TFormatSettings 并改用它。

    var
      fs : TFormatSettings;
    begin
       fs := TFormatSettings.Create();
       Result:=StrToFloat(StringReplace(String(tS),'.',fs.DecimalSeparator,[]));
    end;
    

    【讨论】:

    • 我知道 FormatSettings 不是线程安全的,但它真的被弃用了吗?
    • FormatSettings 没有被弃用,它们只是被重构为一个记录结构。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 2013-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多