home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / comm.swg / 0071_Nodelist Organizer.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-26  |  1.7 KB  |  75 lines

  1. {
  2. For those who are active in other nets than fidonet, and who regularly get a
  3. new small nodelist as an update, this little program gets rid of all but the
  4. latest nodelists, allowing the whole process to be handled by a simple batch
  5. file.Easily adaptable to the names of your nodelists, see last lines.
  6. }
  7.  
  8. Program clean;
  9. {$M 16384,80000,80000}
  10.  
  11. Uses Dos,Crt;
  12.  
  13. TYPE
  14.   Line     = string[80];
  15.   Lines    = ARRAY[1..100] OF Line;
  16.   LinesP   = ^Lines;
  17.  
  18. var
  19.   Dirbuf   : LinesP;
  20.   Index,Number,i,j:integer;
  21.   dirinfo:SearchRec;
  22.   filetime:array[1..100] of longint;
  23.   latest:longint;
  24.   f:file;
  25.  
  26. Procedure remove(s:string);
  27.  
  28. Begin
  29. New(Dirbuf);
  30. Number:=0;
  31.   FindFirst(s+'.*', Anyfile, DirInfo);
  32.     while DosError = 0 do
  33.      begin
  34.       if (Dirinfo.name[1] <> '.') AND (dirinfo.attr<>16) then
  35.           {attribute 16 would be directory file}
  36.             begin
  37.       inc(Number);
  38.       Dirbuf^[Number]:=Dirinfo.name;
  39.       filetime[Number]:=Dirinfo.time;
  40.             end;
  41.  
  42.       FindNext(DirInfo);
  43.      end;
  44.  
  45. if Number<2 then {only one nodelist.nnn found, do nothing.}
  46.             Begin
  47.             dispose(dirbuf);
  48.             exit;
  49.             End;
  50.  
  51. latest:=filetime[1]; {you have to start somewhere}
  52.  
  53. for i:=1 to Number do if filetime[i]>=latest then
  54.                    Begin
  55.                    latest:=filetime[i];
  56.                    Index:=i;
  57.                    End;
  58. {Index now points to the newest file, so this is the one
  59.  that we should NOT erase!}
  60. for i:=1 to Number do if i<>Index then
  61.  Begin
  62.   assign(f,DIRBUF^[I]);
  63.   erase(f);
  64.  End;
  65.  
  66. Dispose(Dirbuf);
  67.  
  68. end;
  69.  
  70. Begin {OF MAIN PROGRAM}
  71. remove('TATTLE');
  72. remove('22NET-NL');
  73. remove('NODELIST');
  74. End.
  75.