mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 12:26:58 +02:00
* Bug ID #29779, add DWord versions of StrToInt
git-svn-id: trunk@33153 -
This commit is contained in:
parent
b38b3a7c1e
commit
5568ee5513
@ -845,6 +845,19 @@ begin
|
||||
if Error <> 0 then raise EConvertError.createfmt(SInvalidInteger,[S]);
|
||||
end;
|
||||
|
||||
function StrToDWord(const s: string): DWord;
|
||||
var Error: word;
|
||||
begin
|
||||
Val(S, result, Error);
|
||||
if Error <> 0 then raise EConvertError.createfmt(SInvalidInteger,[S]);
|
||||
end;
|
||||
|
||||
function TryStrToDWord(const s: string; Out D: DWord): boolean;
|
||||
var Error : word;
|
||||
begin
|
||||
Val(s, D, Error);
|
||||
TryStrToDWord:=Error=0
|
||||
end;
|
||||
|
||||
function TryStrToQWord(const s: string; Out Q: QWord): boolean;
|
||||
var Error : word;
|
||||
@ -863,6 +876,16 @@ begin
|
||||
if Error <> 0 then result := Default;
|
||||
end ;
|
||||
|
||||
{ StrToDWordDef converts the string S to an DWord value,
|
||||
Default is returned in case S does not represent a valid DWord value }
|
||||
|
||||
function StrToDWordDef(const S: string; Default: DWord): DWord;
|
||||
var Error: word;
|
||||
begin
|
||||
Val(S, result, Error);
|
||||
if Error <> 0 then result := Default;
|
||||
end;
|
||||
|
||||
{ StrToInt64Def converts the string S to an int64 value,
|
||||
Default is returned in case S does not represent a valid int64 value }
|
||||
|
||||
|
@ -111,12 +111,15 @@ function IntToHex(Value: Longint; Digits: integer): string;
|
||||
function IntToHex(Value: Int64; Digits: integer): string;
|
||||
function IntToHex(Value: QWord; Digits: integer): string;
|
||||
function StrToInt(const s: string): Longint;
|
||||
function TryStrToInt(const s: string; Out i : Longint) : boolean;
|
||||
function StrToDWord(const s: string): DWord;
|
||||
function StrToInt64(const s: string): int64;
|
||||
function TryStrToInt64(const s: string; Out i : int64) : boolean;
|
||||
function StrToQWord(const s: string): QWord;
|
||||
function TryStrToInt(const s: string; Out i : Longint) : boolean;
|
||||
function TryStrToDWord(const s: string; Out D : DWord) : boolean;
|
||||
function TryStrToInt64(const s: string; Out i : int64) : boolean;
|
||||
function TryStrToQWord(const s: string; Out Q : QWord) : boolean;
|
||||
function StrToIntDef(const S: string; Default: Longint): Longint;
|
||||
function StrToDWordDef(const S: string; Default: DWord): DWord;
|
||||
function StrToInt64Def(const S: string; Default: int64): int64;
|
||||
function StrToQWordDef(const S: string; Default: QWord): QWord;
|
||||
function LoadStr(Ident: integer): string;
|
||||
|
Loading…
Reference in New Issue
Block a user