mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 18:39:52 +02:00
TAChart: Extract StrToFloatDefSep utility function
git-svn-id: trunk@31835 -
This commit is contained in:
parent
4ce550af73
commit
cf6ddb9fb0
@ -262,6 +262,9 @@ function SafeInRange(AValue, ABound1, ABound2: Double): Boolean;
|
|||||||
|
|
||||||
procedure SetPropDefaults(AObject: TPersistent; APropNames: array of String);
|
procedure SetPropDefaults(AObject: TPersistent; APropNames: array of String);
|
||||||
|
|
||||||
|
// Accept both locale-specific and default decimal separators.
|
||||||
|
function StrToFloatDefSep(const AStr: String): Double;
|
||||||
|
|
||||||
// Call this to silence 'parameter is unused' hint
|
// Call this to silence 'parameter is unused' hint
|
||||||
procedure Unused(const A1);
|
procedure Unused(const A1);
|
||||||
procedure Unused(const A1, A2);
|
procedure Unused(const A1, A2);
|
||||||
@ -418,6 +421,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
DefSeparatorSettings: TFormatSettings;
|
||||||
|
|
||||||
|
function StrToFloatDefSep(const AStr: String): Double;
|
||||||
|
begin
|
||||||
|
if
|
||||||
|
not TryStrToFloat(AStr, Result, DefSeparatorSettings) and
|
||||||
|
not TryStrToFloat(AStr, Result)
|
||||||
|
then
|
||||||
|
Result := 0.0;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure Unused(const A1);
|
procedure Unused(const A1);
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
@ -749,6 +764,8 @@ end;
|
|||||||
initialization
|
initialization
|
||||||
|
|
||||||
DrawData := TDrawDataRegistry.Create;
|
DrawData := TDrawDataRegistry.Create;
|
||||||
|
DefSeparatorSettings := DefaultFormatSettings;
|
||||||
|
DefSeparatorSettings.DecimalSeparator := '.';
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
|
|
||||||
|
@ -290,7 +290,6 @@ procedure TListChartSourceStrings.Parse(
|
|||||||
var
|
var
|
||||||
p: Integer = 0;
|
p: Integer = 0;
|
||||||
parts: TStringList;
|
parts: TStringList;
|
||||||
fs: TFormatSettings;
|
|
||||||
|
|
||||||
function NextPart: String;
|
function NextPart: String;
|
||||||
begin
|
begin
|
||||||
@ -301,21 +300,9 @@ var
|
|||||||
p += 1;
|
p += 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function S2F(const AStr: String): Double;
|
|
||||||
begin
|
|
||||||
// Accept both locale-specific and default decimal separators.
|
|
||||||
if
|
|
||||||
not TryStrToFloat(AStr, Result, fs) and
|
|
||||||
not TryStrToFloat(AStr, Result)
|
|
||||||
then
|
|
||||||
Result := 0.0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
fs := DefaultFormatSettings;
|
|
||||||
fs.DecimalSeparator := '.';
|
|
||||||
parts := TStringList.Create;
|
parts := TStringList.Create;
|
||||||
try
|
try
|
||||||
parts.Delimiter := '|';
|
parts.Delimiter := '|';
|
||||||
@ -324,11 +311,11 @@ begin
|
|||||||
if FSource.YCount + 3 < Cardinal(parts.Count) then
|
if FSource.YCount + 3 < Cardinal(parts.Count) then
|
||||||
FSource.YCount := parts.Count - 3;
|
FSource.YCount := parts.Count - 3;
|
||||||
with ADataItem^ do begin
|
with ADataItem^ do begin
|
||||||
X := S2F(NextPart);
|
X := StrToFloatDefSep(NextPart);
|
||||||
if FSource.YCount > 0 then begin
|
if FSource.YCount > 0 then begin
|
||||||
Y := S2F(NextPart);
|
Y := StrToFloatDefSep(NextPart);
|
||||||
for i := 0 to High(YList) do
|
for i := 0 to High(YList) do
|
||||||
YList[i] := S2F(NextPart);
|
YList[i] := StrToFloatDefSep(NextPart);
|
||||||
end;
|
end;
|
||||||
Color := StrToIntDef(NextPart, clTAColor);
|
Color := StrToIntDef(NextPart, clTAColor);
|
||||||
Text := NextPart;
|
Text := NextPart;
|
||||||
|
Loading…
Reference in New Issue
Block a user