View Issue Details

IDProjectCategoryView StatusLast Update
0005742JEDI Code LibraryJclSysUtilspublic2012-08-30 15:32
ReporterAriochAssigned Tooutchy 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product VersionVersion 2.4 
Target VersionFixed in VersionVersion 2.4 
Summary0005742: String to unsigned int conversion ?
Description  // SetOrdValue(StrToInt(Value));
  // Should care for values between high(integer) and high(cardinal)
  // Delphi has UIntToStr() but not StrToUInt()

function StrToUInt(const Value: string): Cardinal;
var i6: Int64;
begin

  i6 := StrToInt64(Value);
  if ( i6 < Low(Result)) or ( i6 > High(Result))
     then raise EConvertError.Create('"'+Value+'" is not within range of Cardinal data type'); //this msg should not end with dot!

  Result := i6;
end;
        
Additional InformationAlso needed is TryStrToUInt, StrToUintDef and maybe something more.

And i seems to saw unsigned UInt64 where shoulbe be no "wrapping" supertype for :-(
TagsNo tags attached.
Fixed in GIT commit
Fixed in SVN revision3817
IDE versionDelphi/C++Builder XE2

Activities

Arioch

2011-12-17 11:04

reporter   ~0019217

// helpers for SetOrdValue(StrToInt(Value:Cardinal));
  // Should care for values between high(integer) and high(cardinal)
  // Delphi has UIntToStr() but not StrToUInt()
  // better be moved to JclSysUtils

function TryStrToUInt(const Value: string; out Res: Cardinal): boolean;
var i6: Int64;
begin
  Result := false;
  if not TryStrToInt64(Value, i6) then exit;
  if ( i6 < Low(Res)) or ( i6 > High(Res)) then exit;
  
  Result := true;
  Res := i6;
end;

function StrToUIntDef(const Value: string; const Default: Cardinal): Cardinal;
begin
  if not TryStrToUInt(Value, Result)
     then Result := Default;
end;
  
function StrToUInt(const Value: string): Cardinal;
begin
  if not TryStrToUInt(Value, Result)
     then raise EConvertError.Create('"'+Value+'" is not within range of Cardinal data type');
end;

Arioch

2011-12-29 23:01

reporter   ~0019284

when implemented, those functions are to be removed from JVCL, design\JvIP4AdressProp 0005716

outchy

2012-02-17 21:09

administrator   ~0019431

This is committed in revision 3732.

Arioch

2012-04-15 18:59

reporter   ~0019707

i see functions were renamed.

i think this renaming is unlucky desicion, sinse it is going to diverge with Delphi RTL naming conventions.

http://docwiki.embarcadero.com/Libraries/en/System.SysUtils.UIntToStr - not CardinalToStr

Arioch

2012-06-11 22:46

reporter   ~0019880

Guys ?

outchy

2012-08-13 15:01

administrator   ~0020093

This renaming is committed in JCL revision 3817 and JVCL revision 13396.

Issue History

Date Modified Username Field Change
2011-12-17 00:17 Arioch New Issue
2011-12-17 00:17 Arioch IDE version => Delphi/C++Builder XE2
2011-12-17 11:04 Arioch Note Added: 0019217
2011-12-29 23:01 Arioch Note Added: 0019284
2012-02-17 21:09 outchy Note Added: 0019431
2012-02-17 21:09 outchy Assigned To => outchy
2012-02-17 21:09 outchy Status new => feedback
2012-03-03 19:28 outchy Fixed in revision => 3732
2012-03-03 19:28 outchy Status feedback => resolved
2012-03-03 19:28 outchy Fixed in Version => Version 2.4 (Subversion repository/Daily zips)
2012-03-03 19:28 outchy Resolution open => fixed
2012-04-15 18:59 Arioch Note Added: 0019707
2012-04-15 18:59 Arioch Status resolved => feedback
2012-04-15 18:59 Arioch Resolution fixed => reopened
2012-06-11 22:46 Arioch Note Added: 0019880
2012-08-13 15:01 outchy Note Added: 0020093
2012-08-30 15:32 outchy Fixed in revision 3732 => 3817
2012-08-30 15:32 outchy Status feedback => resolved
2012-08-30 15:32 outchy Resolution reopened => fixed