James Mills prologic at comcen.com.au
Mon Nov 4 08:19:28 CET 2002


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:

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;
   r, i, p, c : LongInt;
   t : String;
   r := 0;
   for i := 0 to 3 do
      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);
   StrToAddr := r;

Does someone have a fixed version of this function, or can someone fix
it please?

thank you

More information about the fpc-pascal mailing list