mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 15:32:00 +01: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);
 | 
			
		||||
 | 
			
		||||
// Accept both locale-specific and default decimal separators.
 | 
			
		||||
function StrToFloatDefSep(const AStr: String): Double;
 | 
			
		||||
 | 
			
		||||
// Call this to silence 'parameter is unused' hint
 | 
			
		||||
procedure Unused(const A1);
 | 
			
		||||
procedure Unused(const A1, A2);
 | 
			
		||||
@ -418,6 +421,18 @@ begin
 | 
			
		||||
  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);
 | 
			
		||||
begin
 | 
			
		||||
end;
 | 
			
		||||
@ -749,6 +764,8 @@ end;
 | 
			
		||||
initialization
 | 
			
		||||
 | 
			
		||||
  DrawData := TDrawDataRegistry.Create;
 | 
			
		||||
  DefSeparatorSettings := DefaultFormatSettings;
 | 
			
		||||
  DefSeparatorSettings.DecimalSeparator := '.';
 | 
			
		||||
 | 
			
		||||
finalization
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -290,7 +290,6 @@ procedure TListChartSourceStrings.Parse(
 | 
			
		||||
var
 | 
			
		||||
  p: Integer = 0;
 | 
			
		||||
  parts: TStringList;
 | 
			
		||||
  fs: TFormatSettings;
 | 
			
		||||
 | 
			
		||||
  function NextPart: String;
 | 
			
		||||
  begin
 | 
			
		||||
@ -301,21 +300,9 @@ var
 | 
			
		||||
    p += 1;
 | 
			
		||||
  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
 | 
			
		||||
  i: Integer;
 | 
			
		||||
begin
 | 
			
		||||
  fs := DefaultFormatSettings;
 | 
			
		||||
  fs.DecimalSeparator := '.';
 | 
			
		||||
  parts := TStringList.Create;
 | 
			
		||||
  try
 | 
			
		||||
    parts.Delimiter := '|';
 | 
			
		||||
@ -324,11 +311,11 @@ begin
 | 
			
		||||
    if FSource.YCount + 3 < Cardinal(parts.Count) then
 | 
			
		||||
      FSource.YCount := parts.Count - 3;
 | 
			
		||||
    with ADataItem^ do begin
 | 
			
		||||
      X := S2F(NextPart);
 | 
			
		||||
      X := StrToFloatDefSep(NextPart);
 | 
			
		||||
      if FSource.YCount > 0 then begin
 | 
			
		||||
        Y := S2F(NextPart);
 | 
			
		||||
        Y := StrToFloatDefSep(NextPart);
 | 
			
		||||
        for i := 0 to High(YList) do
 | 
			
		||||
          YList[i] := S2F(NextPart);
 | 
			
		||||
          YList[i] := StrToFloatDefSep(NextPart);
 | 
			
		||||
      end;
 | 
			
		||||
      Color := StrToIntDef(NextPart, clTAColor);
 | 
			
		||||
      Text := NextPart;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user