home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / RA / NOC100.ZIP / NOCARRIE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-10-19  |  3.8 KB  |  135 lines

  1. { NOCARRIER by Chua Chee Wee, Oct 19 1991
  2.   This program analyses RA.LOG and finds out who's losing
  3.   carrier and then send a message to them warning them not
  4.   to do so.
  5.  
  6.   Required programs and/or files.
  7.   RA.LOG(in the same directory as NOCARRIE.EXE)
  8.   MBUTIL.EXE(in the \FD directory)
  9.   NOCARRIE.TXT(in the same directory as RA.LOG)
  10.   }
  11. {$M 4096,0,0}
  12. uses Dos;
  13. const
  14.  MonthStr: Array[1..12] of String[3] = ('Jan', 'Feb', 'Mar', 'Apr',
  15.                                         'May', 'Jun', 'Jul', 'Aug',
  16.                                         'Sep', 'Oct', 'Nov', 'Dec');
  17.  DayStr: Array[0..6] of String[3] = ('Sun', 'Mon', 'Tue', 'Wed',
  18.                                      'Thu', 'Fri', 'Sat');
  19. var
  20. LogFile: Text;
  21. LogLine, UserName: String;
  22. Time: String[8];
  23. Date: String[13];
  24. Garbage: String[2];
  25. LDT, LastDT: Longint;
  26. UserDT, DT: DateTime;
  27. Error, Sec100: Word;
  28. DataFile: File;
  29. LastDate: String[13];
  30. CurrDir: PathStr;
  31. Temp: String[5];
  32.  
  33. function NewInfo(Line: String): Boolean;
  34. begin
  35.  NewInfo := (LogLine<>'') and (LogLine[1]='-');
  36. end;
  37.  
  38. function LostCarrier(Line: String): Boolean;
  39. begin
  40.  LostCarrier := Pos('Lost carrier', Line)<>0;
  41. end;
  42.  
  43. function UserOnline(Line: String): Boolean;
  44. begin
  45.  UserOnline := Pos('on-line', Line)<>0;
  46. end;
  47.  
  48. label Examine, WaitOnline;
  49.  
  50. begin
  51.  FillChar(UserDT, SizeOf(UserDT), 0);
  52.  WriteLn('Carrier Lost! v1.0, Copyright (C) Oct 1991 Chua Chee Wee');
  53.  Assign(DataFile, 'NOCARRIE.DAT');
  54.  {$I-}
  55.  Reset(DataFile);
  56.  {$I+}
  57.  if IOResult<>0 then
  58.   begin
  59.    with DT do
  60.     begin
  61.      Year := 1980; { Scan all RA log entries if run first time }
  62.      Month := 1;
  63.      Day := 1;
  64.     end;
  65.    Rewrite(DataFile);
  66.   end else
  67.   begin
  68.    GetFTime(DataFile, LastDT);
  69.    with DT do
  70.     begin
  71.      GetTime(Hour, Min, Sec, Sec100);
  72.      GetDate(Year, Month, Day, Sec100);
  73.     end;
  74.   end;
  75.  PackTime(DT, LDT);
  76.  SetFTime(DataFile, LDT);
  77.  UnpackTime(LastDT, DT);
  78.  Close(DataFile);
  79.  Assign(LogFile, 'RA.LOG'); { Change this filename to your own RA Logfile}
  80.  Reset(LogFile);
  81.  while not eof(LogFile) do
  82.   begin
  83.    repeat
  84.     ReadLn(LogFile, LogLine);
  85.    until NewInfo(LogLine) or eof(LogFile);
  86. Examine:
  87.    if NewInfo(LogLine) then
  88.     Date := Copy(LogLine, 13, 13);
  89. WaitOnline:
  90.    repeat
  91.     ReadLn(LogFile, LogLine);
  92.    until UserOnline(LogLine) or NewInfo(LogLine);
  93.    while not (UserOnline(LogLine) or eof(LogFile)) do
  94.     ReadLn(LogFile, LogLine);
  95.    if UserOnline(LogLine) then
  96.     begin
  97.      Time := Copy(LogLine, 3, 8);
  98.      UserName := Copy(LogLine, 13, Pos(' on-line', LogLine)-13);
  99.      repeat
  100.       ReadLn(LogFile, LogLine);
  101.       if (Pos('Did not enter a full name', LogLine)<>0) or
  102.          (Pos('Name not in user file', LogLine)<>0) then goto WaitOnline;
  103.      until NewInfo(LogLine) or eof(LogFile) or LostCarrier(LogLine);
  104.      if (LostCarrier(LogLine)) then
  105.       begin
  106.        with UserDT do
  107.         begin
  108.          Temp := Copy(Date, 5, 2);
  109.          Val(Temp, Day, Error);
  110.          Temp := Copy(Date, 8, 3);
  111.          for Error := 1 to 12 do
  112.           if Temp = MonthStr[Error] then Month := Error;
  113.          Temp := Copy(Date, 12, 2);
  114.          Val(Temp, Year, Error);
  115.          Inc(Year, 1900);
  116.         end;
  117.        if (UserDT.Year>=DT.Year) and (UserDT.Month>=DT.Month) and
  118.           (UserDT.Day>=DT.Day) then
  119.         begin
  120.          GetDir(0, CurrDir);
  121.          ChDir('\FD'); { Change this directory to suit your own }
  122.          SwapVectors;
  123.          { \RA\NOCARRIE.TXT
  124.            \RA is a directory which contains NOCARRIE.TXT }
  125.          Exec('MBUTIL.EXE','POST \RA\NOCARRIE.TXT MAIN -To "'+UserName+'" -Subject "Carrier Lost on '+Date+' at '+Time+'"');
  126.          SwapVectors;
  127.          ChDir(CurrDir);
  128.         end;
  129.       end else
  130.      if NewInfo(LogLine) then goto Examine;
  131.     end;
  132.   end;
  133.  Close(LogFile);
  134. end.
  135.