View Issue Details

IDProjectCategoryView StatusLast Update
0001696JEDI VCL00 JVCL Componentspublic2004-04-27 01:13
ReporterSVitaliyAssigned Touser72 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001696: Exists invalid for TJvSpinEdit.DisplayFormat strings, but valid for Delphi FormatFloat function.
DescriptionThe component TJvSpinEdit failed to set value when DisplayFormat contains non-format characters. For example .##’%’.
Possible solution: upgrade function TextToValText in file JvSpinEdit.
TagsNo tags attached.

Activities

user72

2004-04-25 23:40

  ~0004072

Last edited: 2004-04-25 23:42

Not that I think the current behavior is incorrect (it is a spin edit, not a mask edit), the following should fix it:

function TextToValText(const AValue: string): string;
var i, j:integer;
begin

  Result := DelRSpace(AValue);
  if DecimalSeparator <> ThousandSeparator then
    Result := DelChars(Result, ThousandSeparator);

  if (DecimalSeparator <> '.') and (ThousandSeparator <> '.') then
    Result := ReplaceStr(Result, '.', DecimalSeparator);
  if (DecimalSeparator <> ',') and (ThousandSeparator <> ',') then
    Result := ReplaceStr(Result, ',', DecimalSeparator);

  j := 1;
  for i := 1 to Length(Result) do
    if Result[i] in ['0'..'9', DecimalSeparator] then
    begin
      Result[j] := Result[i];
      Inc(j);
    end;
  SetLength(Result, j - 1);


  if Result = '' then
    Result := '0'
  else
  if Result = '-' then
    Result := '-0';
end;

edited on: 04-25-04 23:42

user72

2004-04-26 06:20

  ~0004079

Just to make it clear: I don't think SpinEdit needs to support anything but 0..9, DecimalSeparator (and maybe ThousandsSeparator) since those are the only characters you should be able to put into it.

SVitaliy

2004-04-26 09:53

reporter   ~0004084

I agree with Your statement.
What You say about defense DisplayFormat against incorrect input?

user72

2004-04-26 10:05

  ~0004085

You mean change TextToValText so it just trims out anything invalid and return the rest? I guess that would be feasible...

SVitaliy

2004-04-26 11:21

reporter   ~0004088

I feel that solution found!

remkobonte

2004-04-26 17:16

developer   ~0004089

Note that there is an adjusted TextToValText in JvBaseEdits.pas.

user72

2004-04-27 01:13

  ~0004091

Fixed in CVS: Fixed TextToValText moved to JvJCLUtils

Issue History

Date Modified Username Field Change
2004-04-25 08:38 SVitaliy New Issue
2004-04-25 23:40 user72 Note Added: 0004072
2004-04-25 23:41 user72 Note Edited: 0004072
2004-04-25 23:42 user72 Note Edited: 0004072
2004-04-26 05:29 user72 Status new => feedback
2004-04-26 06:20 user72 Note Added: 0004079
2004-04-26 09:53 SVitaliy Note Added: 0004084
2004-04-26 10:05 user72 Note Added: 0004085
2004-04-26 11:21 SVitaliy Note Added: 0004088
2004-04-26 17:16 remkobonte Note Added: 0004089
2004-04-27 01:13 user72 Status feedback => resolved
2004-04-27 01:13 user72 Resolution open => fixed
2004-04-27 01:13 user72 Assigned To => user72
2004-04-27 01:13 user72 Note Added: 0004091