AdvEdit.FloatValue and Decimalseparator

Hi

AdvEdit.FloatValue:=2;
FormatSettings.DecimalSeparator:='.'  // AdvEdit.FloatValue=0 !!
FormatSettings.DecimalSeparator:=','  // AdvEdit.FloatValue=2

If set the DecimalSeparator to '.', the FloatValue's value changed to 0 !

Thanks in advance.

WIN 7, Delphi XE, TMS CP 6.9.3.0

Was retested here with a default TAdvEdit on the form and all 3 sequences were tested:


begin
  advedit1.FloatValue := 2;
  FormatSettings.DecimalSeparator:=',';  // AdvEdit.FloatValue=2
end;

begin
  advedit1.FloatValue := 2;
  FormatSettings.DecimalSeparator:='.';  // AdvEdit.FloatValue=2
end;

begin
  advedit1.FloatValue := 2;
  FormatSettings.DecimalSeparator:=',';  // AdvEdit.FloatValue=2
  FormatSettings.DecimalSeparator:='.';  // AdvEdit.FloatValue=2
end;

and in all cases, the value of the TAdvEdit remained 2.

Sorry, a piece of information is absent:

AdvEdit.EditType:=etFloat;

By this settings the AdvEdit.FloatValue give wrong value.

Retested with


begin
  advedit1.EditType := etFloat;
  advedit1.FloatValue := 2;
  FormatSettings.DecimalSeparator:=',';  // AdvEdit.FloatValue=2
end;

begin
  advedit1.EditType := etFloat;
  advedit1.FloatValue := 2;
  FormatSettings.DecimalSeparator:='.';  // AdvEdit.FloatValue=2
end;

begin
  advedit1.EditType := etFloat;
  advedit1.FloatValue := 2;
  FormatSettings.DecimalSeparator:=',';  // AdvEdit.FloatValue=2
  FormatSettings.DecimalSeparator:='.';  // AdvEdit.FloatValue=2
end;

and no problem can be seen here with the latest version of TAdvEdit.


Possible it's depend on Windows regional and language settings.
My settings: Format= magyar(Magyarország) and  Region= Magyarország,
This mean, the decimalseparator=',' = comma

This is the simple sample output:
AdvEdit1.Properties=default properties.

I can only suspect that you're not using the latest version.
We cannot reproduce this.
You can download our test app from:

http://www.tmssoftware.net/public/AdvEditTest.zip 

The Test work perfect, but:

1, Set AdvEdit1.Precision from 0 to 2.
2, After the set the DecimalSeparator, get the AdvEdit1.FloatValue !

The AdvEdit1.FloatValue changed wrong  to 0. The displayed value not changed.

In AdvEditTest i changed only the AdvEdit1.Precision to 2, and insert a memo lines.



procedure TForm6.Button1Click(Sender: TObject);
begin
  advedit1.EditType := etFloat;
  advedit1.FloatValue := 2;
  Memo1.Lines.Add( (sender as TButton).Name );
  Memo1.Lines.Add(floattostr(AdvEdit1.FloatValue));
  FormatSettings.DecimalSeparator:=',';
  Memo1.Lines.Add(floattostr(AdvEdit1.FloatValue));
end;

procedure TForm6.Button2Click(Sender: TObject);
begin
  advedit1.EditType := etFloat;
  advedit1.FloatValue := 2;
  Memo1.Lines.Add( (sender as TButton).Name );
  Memo1.Lines.Add(floattostr(AdvEdit1.FloatValue));
  FormatSettings.DecimalSeparator:=',';
  Memo1.Lines.Add(floattostr(AdvEdit1.FloatValue));
  FormatSettings.DecimalSeparator:='.';
  Memo1.Lines.Add(floattostr(AdvEdit1.FloatValue));
end;

procedure TForm6.Button3Click(Sender: TObject);
begin
  advedit1.EditType := etFloat;
  advedit1.FloatValue := 2;
  Memo1.Lines.Add( (sender as TButton).Name );
  Memo1.Lines.Add(floattostr(AdvEdit1.FloatValue));
  FormatSettings.DecimalSeparator:='.';
  Memo1.Lines.Add(floattostr(AdvEdit1.FloatValue));
end;

The problem exists in TMS CP 7.0.3.0 (AdvEdit 3.2.0.3).

If TAdvEdit contains the text 2,0 and behind its back you change the decimal separator to '.'  it is normal that it won't be able to parse 2,0 to value 2. As the conversion fails it returns zero.

This is the expected behavior. I do not get the point of changing the decimalseparator behind the back of TAdvEdit.

It's normal.
Ok.