[fpc-pascal]inetaux.pas
James Mills
prologic at comcen.com.au
Mon Nov 4 08:19:28 CET 2002
Hi,
Could someone help me out here. I didn't even write this pascal file,
yet it throws 'Range Check Errors' in the program particularly with this
ip address: 200.34.32.196
If it chucks an error with that address, the function mustn't work very
well, but I can't seem to see what's wrong with it.
function StrToAddr(s : String) : LongInt;
var
r, i, p, c : LongInt;
t : String;
begin
r := 0;
for i := 0 to 3 do
begin
p := Pos('.', s);
if p = 0 then p := Length(s) + 1;
if p <= 1 then exit;
t := Copy(s, 1, p - 1);
Delete(s, 1, p);
Val(t, p, c);
if (c <> 0) or (p < 0) or (p > 255) then exit;
r := r or p shl (i * 8);
end;
StrToAddr := r;
end;
Does someone have a fixed version of this function, or can someone fix
it please?
thank you
James
More information about the fpc-pascal
mailing list