+ TryStrToInt* added

This commit is contained in:
florian 2004-08-07 16:56:28 +00:00
parent b950207508
commit d4117aeb34
2 changed files with 30 additions and 5 deletions

View File

@ -655,6 +655,14 @@ begin
end ;
{$ENDIF}
function TryStrToInt(const s: string; var i : integer) : boolean;
var Error : word;
begin
Val(s, i, Error);
TryStrToInt:=Error=0
end;
{ StrToInt converts the string S to an integer value,
if S does not represent a valid integer value EConvertError is raised }
@ -680,7 +688,16 @@ var Error: word;
begin
Val(S, result, Error);
if Error <> 0 then raise EConvertError.createfmt(SInValidInteger,[S]);
end ;
end;
function TryStrToInt64(const s: string; var i : int64) : boolean;
var Error : word;
begin
Val(s, i, Error);
TryStrToInt64:=Error=0
end;
{ StrToIntDef converts the string S to an integer value,
@ -2175,7 +2192,10 @@ const
{
$Log$
Revision 1.13 2004-06-13 10:49:50 florian
Revision 1.14 2004-08-07 16:56:28 florian
+ TryStrToInt* added
Revision 1.13 2004/06/13 10:49:50 florian
* fixed some bootstrapping problems as well as some 64 bit stuff
Revision 1.12 2004/06/12 13:57:18 michael
@ -2272,4 +2292,4 @@ const
instead of direct comparisons of low/high values of orddefs because
qword is a special case
}
}

View File

@ -118,8 +118,10 @@ function IntToStr(Value: QWord): string;
function IntToHex(Value: integer; Digits: integer): string;
function IntToHex(Value: Int64; Digits: integer): string;
function StrToInt(const s: string): integer;
function TryStrToInt(const s: string; var i : integer) : boolean;
{$IFNDEF VIRTUALPASCAL}
function StrToInt64(const s: string): int64;
function TryStrToInt64(const s: string; var i : int64) : boolean;
{$ENDIF}
function StrToIntDef(const S: string; Default: integer): integer;
{$IFNDEF VIRTUALPASCAL}
@ -190,7 +192,10 @@ function BCDToInt(Value: integer): integer;
{
$Log$
Revision 1.7 2004-06-20 20:42:37 florian
Revision 1.8 2004-08-07 16:56:28 florian
+ TryStrToInt* added
Revision 1.7 2004/06/20 20:42:37 florian
* fixed bootstrapping problems
Revision 1.6 2004/06/13 10:49:50 florian
@ -255,4 +260,4 @@ function BCDToInt(Value: integer): integer;
instead of direct comparisons of low/high values of orddefs because
qword is a special case
}
}