When using StrToFloat with a second parameter, which is a local format setting, the compiler gives an error message. Below is an example:
procedure TForm1.ConvertString;
var
i: Integer;
aReal: Double;
aStr: UnicodeString;
LocalFormatSettings: TFormatSettings;
begin { TForm1.ConvertString }
aStr := '1.05';
LocalFormatSettings := TFormatSettings.Create;
aReal := **StrToFloat(aStr, LocalFormatSettings)**;
end { TForm1.ConvertString };
The compiler gives the message: "Wrong number of parameters specified for call to "function StrToFloat(String)".
However, the unit System.SysUtils offers both possibilities: only a string or a string and format settings, as can be seen below.
function StrToFloat(const S: string): Extended;
begin
Result := StrToFloat(S, FormatSettings);
end;
function StrToFloat(const S: string;
const AFormatSettings: TFormatSettings): Extended;
begin
if not TextToFloat(S, Result, AFormatSettings) then
ConvertErrorFmt(@SInvalidFloat, [S]);
end;
Does the compiler use a different System.SysUtils unit? How can I use this second form of StrToFloat?
The question also applies to FloatToStrF and FormatDateTime, which also cannot be used with a format setting parameter.