home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2007 April / PCpro_2007_04.ISO / files / dsl / NVinst.exe / Scripts / Scripter / ExtendedSubnetAutosplit.nvs < prev    next >
Encoding:
Text File  |  2007-02-10  |  1.1 KB  |  58 lines

  1. {
  2. This script provides extended possibilites to split hostlist on sublists
  3. By default it splits it by subnet mask 255.255.0.0
  4. This can be changed by editing GetSublistName function
  5. }
  6. program ExtendedSubnetAutosplit;
  7. const RethinkInterval=300;//in seconds
  8.  
  9. function GetSublistName(hst:TNVHost):string;
  10. var ret,ip:string;
  11.     i,j:integer;
  12. begin
  13. ret:='';
  14. ip:=hst.hip;
  15. if length(ip)<>0 then
  16.  begin
  17.  j:=0;
  18.  for i:=1 to length(ip) do
  19.   begin
  20.   if j<2 then ret:=ret+ip[i];
  21.   if ip[i]='.' then j:=j+1;
  22.   end;
  23.  ret:=ret+'x.x';
  24.  end;
  25. Result:=ret;
  26. end;
  27.  
  28. var hst:TNVHost;
  29.     v,v1,v2:integer;
  30.     newlist,oldlist:string;
  31. begin
  32. hst:=TNVHost.create;
  33. SetTimer(RethinkInterval*1000);
  34. repeat
  35. v:=WaitEvent(v1,v2);
  36. if(v=8)then
  37. begin
  38. hst.nextid:=0;
  39.  repeat
  40.  hst.GetHost(hst.nextid,0);
  41.  if(hst.id<>0)then
  42.   begin
  43.   oldlist:=hst.GetMetaVar('map');
  44.   newlist:=GetSublistName(hst);
  45.   if (oldlist<>newlist) and (length(newlist)<>0) then
  46.    begin
  47.    hst.SetMetaVar('map',newlist);
  48.    Action(NVACTION_SETSTATE,hst.id);
  49.    end;
  50.   end;
  51.  until hst.nextid=0;
  52. end;
  53. until v=0;
  54. SetTimer(0);
  55. hst.Free;
  56. end.
  57.  
  58.