mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 18:25:58 +02:00
+ TryStrToInt* added
This commit is contained in:
parent
b950207508
commit
d4117aeb34
@ -655,6 +655,14 @@ begin
|
|||||||
end ;
|
end ;
|
||||||
{$ENDIF}
|
{$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,
|
{ StrToInt converts the string S to an integer value,
|
||||||
if S does not represent a valid integer value EConvertError is raised }
|
if S does not represent a valid integer value EConvertError is raised }
|
||||||
|
|
||||||
@ -680,7 +688,16 @@ var Error: word;
|
|||||||
begin
|
begin
|
||||||
Val(S, result, Error);
|
Val(S, result, Error);
|
||||||
if Error <> 0 then raise EConvertError.createfmt(SInValidInteger,[S]);
|
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,
|
{ StrToIntDef converts the string S to an integer value,
|
||||||
@ -2175,7 +2192,10 @@ const
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$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
|
* fixed some bootstrapping problems as well as some 64 bit stuff
|
||||||
|
|
||||||
Revision 1.12 2004/06/12 13:57:18 michael
|
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
|
instead of direct comparisons of low/high values of orddefs because
|
||||||
qword is a special case
|
qword is a special case
|
||||||
|
|
||||||
}
|
}
|
@ -118,8 +118,10 @@ function IntToStr(Value: QWord): string;
|
|||||||
function IntToHex(Value: integer; Digits: integer): string;
|
function IntToHex(Value: integer; Digits: integer): string;
|
||||||
function IntToHex(Value: Int64; Digits: integer): string;
|
function IntToHex(Value: Int64; Digits: integer): string;
|
||||||
function StrToInt(const s: string): integer;
|
function StrToInt(const s: string): integer;
|
||||||
|
function TryStrToInt(const s: string; var i : integer) : boolean;
|
||||||
{$IFNDEF VIRTUALPASCAL}
|
{$IFNDEF VIRTUALPASCAL}
|
||||||
function StrToInt64(const s: string): int64;
|
function StrToInt64(const s: string): int64;
|
||||||
|
function TryStrToInt64(const s: string; var i : int64) : boolean;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
function StrToIntDef(const S: string; Default: integer): integer;
|
function StrToIntDef(const S: string; Default: integer): integer;
|
||||||
{$IFNDEF VIRTUALPASCAL}
|
{$IFNDEF VIRTUALPASCAL}
|
||||||
@ -190,7 +192,10 @@ function BCDToInt(Value: integer): integer;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$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
|
* fixed bootstrapping problems
|
||||||
|
|
||||||
Revision 1.6 2004/06/13 10:49:50 florian
|
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
|
instead of direct comparisons of low/high values of orddefs because
|
||||||
qword is a special case
|
qword is a special case
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user