I am using Inno Setup and want to check with Pascal Script if the string variable is Integer (only 0-9, without hex). I made this function:
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 changed the line to this:
if not (s[i] in ['0','1','2','3','4','5','6','7','8','9']) then
It matches, but if the code is executing, it gives this error:
Runtime Error - Invalid Type.
What to do?
source
share