Gu3st...
2011-04-01 21:46:51
begin
WriteLn(StrToInt('hi'));
end.
Compiled succesfully in 15 ms.
-1
Successfully executed.AFAIK, "hi" is not a number, but Simba says it is the same as "-1"… Why doesn't it result in an error???
2011-04-01 21:46:51
begin
WriteLn(StrToInt('hi'));
end.
Compiled succesfully in 15 ms.
-1
Successfully executed.2011-04-01 21:49:28
2011-04-01 21:53:39
2011-04-01 21:57:10
2011-04-01 21:58:12
2011-04-01 22:00:29
2011-04-01 22:01:41
StrToBool('') -> Error: Exception: "" is not a valid boolean. at line 3Therefore StrToInt('hi') should throw Error: Exception: "hi" is not a valid integer. at line 3
2011-04-02 01:37:35
2011-04-02 06:21:40
2011-04-02 14:48:21
From: Zyt3x
It did throw an error before iirc… Wonder what changed :confused:
2011-04-02 15:22:58
2011-04-02 15:27:45
2011-04-02 15:30:18
2011-04-02 15:38:09
From: Smartzkid
In those cases, you would use StrToIntDef
2011-04-02 17:05:25
2011-04-02 18:30:41
From: Wizzup?Thanks, and done.
I think it should raise an exception. Please file a bug. :)
2011-04-07 15:33:09
function StrToInt(const S: TbtString): LongInt;
var
e: Integer;
Res: LongInt;
begin
Val(string(S), Res, e);
if e <> 0 then
StrToInt := -1
else
StrToInt := Res;
end;
2011-04-08 06:12:42
2011-04-08 06:18:23
From: Coh3n
Well tell them to change it back!
But if not.. couldn't some form of wrapper function be made to overwrite the PS version? If absolutely necessary of course.
2011-04-08 10:40:12
if e <> 0 then
ThrowError(); //
else
StrToInt := Res;
2011-04-08 12:21:08
From: Zyt3x
I already added a note to bugs.villavu.com, but I'll post here too..
We can change it toif e <> 0 then
ThrowError(); //
else
StrToInt := Res;
2011-04-08 12:28:11
2011-04-08 13:23:49
2011-04-08 13:28:56
From: nielsie95
We should just use the StrToInt from FPC/Lazarus.
2011-04-08 15:06:46
From: Coh3nnope, e is <> 0 when there is an error :)
<> -1, you mean? What if the string is actually '-1'?
From: nielsie95:D
We should just use the StrToInt from FPC/Lazarus.
2011-04-09 17:50:30
2011-04-09 19:07:51