Function Checkip(const Ip:String):byte;
var
i,k:Integer;
s1:String;
begin
Result:=0;
s1:=Ip;
i:= Pos('.',s1);
s1 := s1 + '.';
while i > 0 do
begin
if not Length(Copy(s1,1,i)) in [2..4] then
break;
k:=StrTointDef(Copy(s1,1,i-1),-1);
if (k<0) or (k>255) then
Break;
inc(Result);
if Result>4 then
Exit;
system.Delete(s1,1,i);
i:= Pos('.',s1);
end;
end;