Merged revisions 2148 via svnmerge from

http://svn.freepascal.org/svn/fpc/trunk

........
r2148 | florian | 2006-01-03 23:15:22 +0100 (Di, 03 Jan 2006) | 2 lines

+ StrToQWord patch from Vincent Snijders

........

git-svn-id: branches/fixes_2_0@2154 -
This commit is contained in:
florian 2006-01-04 10:29:07 +00:00
parent a13da214ac
commit a84dc15a94
2 changed files with 32 additions and 7 deletions

View File

@ -773,7 +773,6 @@ end ;
function StrToInt64(const S: string): int64;
var Error: word;
begin
Val(S, result, Error);
if Error <> 0 then raise EConvertError.createfmt(SInvalidInteger,[S]);
@ -788,6 +787,20 @@ begin
end;
function StrToQWord(const s: string): QWord;
var Error: word;
begin
Val(S, result, Error);
if Error <> 0 then raise EConvertError.createfmt(SInvalidInteger,[S]);
end;
function TryStrQWord(const s: string; var i: QWord): boolean;
var Error : word;
begin
Val(s, i, Error);
TryStrQWord:=Error=0
end;
{ StrToIntDef converts the string S to an integer value,
Default is returned in case S does not represent a valid integer value }
@ -795,20 +808,29 @@ end;
function StrToIntDef(const S: string; Default: integer): integer;
var Error: word;
begin
Val(S, result, Error);
if Error <> 0 then result := Default;
Val(S, result, Error);
if Error <> 0 then result := Default;
end ;
{ StrToIntDef converts the string S to an integer value,
Default is returned in case S does not represent a valid integer value }
{ StrToInt64Def converts the string S to an int64 value,
Default is returned in case S does not represent a valid int64 value }
function StrToInt64Def(const S: string; Default: int64): int64;
var Error: word;
begin
Val(S, result, Error);
if Error <> 0 then result := Default;
Val(S, result, Error);
if Error <> 0 then result := Default;
end ;
{ StrToQWordDef converts the string S to an QWord value,
Default is returned in case S does not represent a valid QWord value }
function StrToQWordDef(const S: string; Default: QWord): QWord;
var Error: word;
begin
Val(S, result, Error);
if Error <> 0 then result := Default;
end;
{ LoadStr returns the string resource Ident. }

View File

@ -107,8 +107,11 @@ function StrToInt(const s: string): integer;
function TryStrToInt(const s: string; var i : integer) : boolean;
function StrToInt64(const s: string): int64;
function TryStrToInt64(const s: string; var i : int64) : boolean;
function StrToQWord(const s: string): QWord;
function TryStrQWord(const s: string; var i : QWord) : boolean;
function StrToIntDef(const S: string; Default: integer): integer;
function StrToInt64Def(const S: string; Default: int64): int64;
function StrToQWordDef(const S: string; Default: QWord): QWord;
function LoadStr(Ident: integer): string;
// function FmtLoadStr(Ident: integer; const Args: array of const): string;
Function Format (Const Fmt : String; const Args : Array of const) : String;