I'm using Inno Setup and want to check with Pascal Script if a string variable is an Integer (0-9 only, no hex). I have made this funcion:
function IsInt(s: string): boolean;
var
i, len: Integer;
begin
len := length(s);
if len = 0 then
result := false
else
begin
result := true;
for i := 1 to len do
begin
if not (s[i] in ['0'..'9']) then !!! ERROR HERE !!!
begin
result := false;
exit;
end;
end;
end;
end;
But the compiler raises an error:
Closing square bracket (']') expected.
How to fix it?
If I change the line to this:
if not (s[i] in ['0','1','2','3','4','5','6','7','8','9']) then
It complies but if the code is executed it gives this error:
Runtime Error - Invalid Type.
What to do?
String
is aNumber
, notInteger
. Am I right? Because you don't need it to Return True when it passes a HEX Number. – GTAVLover