home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 12 / CD_ASCQ_12_0294.iso / vrac / qwsample.zip / LOGTOTAL.SCR < prev    next >
Text File  |  1994-01-11  |  3KB  |  118 lines

  1. ' This script reads a QmodemPro for Windows log file and produces a total
  2. ' summary of the connect times.
  3.  
  4. dialog FilenameDialog 100, 100, 200, 90
  5.   caption "Report log file summary"
  6.   groupbox "", -1, 5, 5, 190, 55
  7.   ltext "Log file", -1, 10, 16, 40, 12
  8.   LogFile as edittext 101, 50, 15, 130, 12
  9.   ltext "Output file", -1, 10, 36, 40, 12
  10.   OutputFile as edittext 102, 50, 35, 130, 12
  11.   defpushbutton "OK", IDOK, 40, 65, 50, 14
  12.   pushbutton "Cancel", IDCANCEL, 110, 65, 50, 14
  13. end dialog
  14.  
  15. dim fd as FilenameDialog
  16.  
  17. const MaxNames = 100
  18. dim names(MaxNames) as string
  19. dim times(MaxNames) as integer
  20. dim count as integer
  21. dim index as integer
  22. dim firstdate as string
  23. dim lastdate as string
  24.  
  25. function ReadLogFile as integer
  26.   ReadLogFile = False
  27.   open fd.LogFile for input as #1
  28.   print "Processing...";
  29.   do while not eof(1)
  30.     dim s as string
  31.     input #1, s
  32.     if mid(s, 3, 1) = ":" then
  33.       if firstdate = "" then
  34.         firstdate = mid(s, 10, 8)
  35.       end if
  36.       lastdate = mid(s, 10, 8)
  37.       if mid(s, 20, 10) = "Connect to" then
  38.         dim sname as string
  39.         sname = mid(s, 31, instr(s, " at ")-31)
  40.         index = 1
  41.         do while index <= count
  42.           if sname = names(index) then
  43.             exit do
  44.           end if
  45.           index = index + 1
  46.         loop
  47.         if index > count and index <= MaxNames then
  48.           names(index) = sname
  49.           times(index) = 0
  50.           count = index
  51.         end if
  52.         print ".";
  53.       elseif mid(s, 20, 18) = "Total connect time" and index > 0 then
  54.         times(index) = times(index) + val(mid(s, 39, 2))*3600 + val(mid(s, 42, 2))*60 + val(mid(s, 45, 2))
  55.         index = 0
  56.       end if
  57.     end if
  58.   loop
  59.   close #1
  60.   print
  61.   ReadLogFile = True
  62. catch err_fileopen
  63.   MsgBox "Error opening log file "+fd.LogFile
  64. end function
  65.  
  66. function PrintResults as integer
  67.   PrintResults = False
  68.   open fd.OutputFile for output as #1
  69.   print #1, "QmodemPro for Windows Log Summary"
  70.   print #1, "================================="
  71.   print #1,
  72.   print #1, "Starting date: "; firstdate
  73.   print #1, "  Ending date: "; lastdate
  74.   print #1,
  75.   print #1, "Service name                       Total time"
  76.   print #1, "------------------------------     ----------"
  77.   if count > 0 then
  78.     for index = 1 to count
  79.       print #1, names(index); space(35-len(names(index)));
  80.       dim hours as integer, minutes as integer, seconds as integer
  81.       hours = times(index)/3600
  82.       minutes = int(times(index)/60) mod 60
  83.       seconds = times(index) mod 60
  84.       print #1, space(3-len(str(hours))); hours; ":";
  85.       if minutes < 10 then
  86.         print #1, "0";
  87.       end if
  88.       print #1, minutes; ":";
  89.       if seconds < 10 then
  90.         print #1, "0";
  91.       end if
  92.       print #1, seconds
  93.     next
  94.   else
  95.     print #1, "(no entries found)"
  96.   end if
  97.   print #1,
  98.   close #1
  99.   PrintResults = True
  100. catch err_fileopen
  101.   MsgBox "Error creating log file "+fd.OutputFile
  102. end function
  103.  
  104. fd.LogFile = "qmwin.log"
  105. fd.OutputFile = "qmwin.out"
  106. if dialogbox(fd) = IDCANCEL then end
  107.  
  108. firstdate = ""
  109. lastdate = ""
  110. count = 0
  111. index = 0
  112.  
  113. if ReadLogFile then
  114.   if PrintResults then
  115.     viewfile fd.OutputFile
  116.   end if
  117. end if
  118.