home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / lorautil.zip / EOM.CMD < prev    next >
OS/2 REXX Batch file  |  1995-05-08  |  7KB  |  211 lines

  1. /* EOM.CMD - Program to count messages received for past MONTH
  2.     version 1.0, 19 February, 1995 by Elliott Goodman 
  3.  
  4.     This is configured for MY system. Most likely, you'll have to make
  5.     a few changes to drives and paths, file names, etc. PLEASE read
  6.     thru the program before running it! On your head be the consequences!!
  7.  
  8.     Get LOG.CMD from 1:102/1319 and use to compile daily stats from the
  9.     logfile.
  10.  
  11. Donations for this program may be sent to:
  12.  
  13.      Elliott Goodman        
  14.      PO Box 500038          
  15.      Palmdale, CA 93591-0038
  16.  
  17. */
  18.  
  19. /* trace ?a */
  20.  
  21. say 'Monthly Message Stats Compiler by Elliott Goodman'
  22. say ' '
  23. say 'Creating Monster logfile. Wait a mo....'
  24.  
  25. /* load if not already loaded */
  26. /*if RxFuncQuery('SysLoadFuncs') then
  27. do
  28.         call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  29.         call SysLoadFuncs
  30. end
  31. */
  32.  
  33. old_dir = directory()
  34. call directory('D:\TEMP')
  35.  
  36. '@unzip d:\lora\lang\oldlora.zip 1>NUL 2>&1'
  37. '@del init.log 1>NUL 2>&1'
  38. '@copy *.log LORA.TMP 1>NUL 2>&1'
  39. '@del *.log 1>NUL 2>&1'
  40.  
  41. say 'Now beginning gonzo scanning! Please wait....'
  42. call time('R')
  43.  
  44. /* initialize variables */
  45. phrase1 = 'Tossing'
  46. phrase2 = 'packet(s):'
  47.  
  48. in_name = 'lora.TMP'
  49. out_name = 'EOM.TXT'
  50. toss_flag = 0
  51. toss_pattern = '(Toss='
  52. area_names = 0
  53. temp_name = ' '
  54. temp_count = 0
  55. total_count = 0
  56.  
  57. drop messages.
  58.  
  59. /* Initialize Output file with date/time */
  60. m_txt = 'End of Month Message Count v1.0 by Elliott Goodman'
  61. call lineout out_name, m_txt
  62. m_txt = '  '
  63. call lineout out_name, m_txt
  64. m_txt = 'Messages received Previous Month'
  65. call lineout out_name, m_txt
  66. time_string = time('C')
  67. date_string = date('N')
  68. m_txt = 'Current time:' time_string || ',' date_string
  69. call lineout out_name, m_txt
  70. m_txt = '  '
  71. call lineout out_name, m_txt
  72.  
  73. /* cycle thru LORA.TMP */
  74. do until lines(in_name) = 0
  75.     work_line = linein(in_name)
  76.  
  77. /* set further-work flag. This should avoid messing with
  78. irrelevant lines and speed things up */
  79.  
  80.     if toss_flag = 0 then do
  81.         j = wordpos(phrase1, work_line)
  82.         if j \= 0 then
  83.             toss_flag = 1
  84.         end /* if toss_flag <> 1 */
  85.  
  86.     if toss_flag = 1 then do
  87.         j = wordpos(phrase2, work_line)
  88.         if j \= 0 then
  89.             toss_flag = 0
  90.         end /* if toss_flag = 1 */
  91.  
  92. /* found block of lines headed by 'Tossing */
  93.     if toss_flag = 1 then do
  94. /* break up line into elements */
  95.         parse var work_line . . area_tag toss_count stuff
  96. /* if line contains (Toss=xxxx) then work on it */
  97.         if left(toss_count, 6) = '(Toss=' then do
  98.  
  99. /* remove trailing space, if present */
  100.             toss_count = strip(toss_count)
  101. /* remove leading '(Toss=' stuff */
  102.             parse var toss_count (toss_pattern) toss_count
  103. /* remove trailing ')' - should now be of form '000x' */
  104.             toss_count = strip(toss_count, 'T', ')' )
  105.  
  106. /* search thru array for area tag and increment if found */
  107.             found = 0
  108.             do index = 1 to area_names
  109.                 if messages.index = area_tag then do
  110.                     messages.index.count = messages.index.count + toss_count
  111.                     found = 1
  112.                     leave
  113.                     end /* if */
  114.                 end /* do index = 1 to area_names */
  115.  
  116. /* area tag not found; add to array */
  117.              if found = 0 then do
  118.                  area_names = area_names + 1
  119.                  messages.area_names = area_tag
  120.                  messages.area_names.count = toss_count
  121.                  end /* if found = 0 */
  122.             end /* if left = (Toss */
  123.         end /* if toss_flag = 1 */
  124.     end /* do until lines() = 0 */
  125.  
  126. /* sort routine - not fast but it works */
  127. swap = 1
  128. do until swap = 0
  129.     swap = 0
  130.     do index = 1 to area_names -1
  131.         t_index = index + 1
  132.         if messages.t_index.count > messages.index.count then do
  133.             temp_name = messages.index
  134.             temp_count = messages.index.count
  135.             messages.index = messages.t_index
  136.             messages.index.count = messages.t_index.count
  137.             messages.t_index = temp_name
  138.             messages.t_index.count = temp_count
  139.             swap = 1
  140.             end /* if */
  141.         end /* do */
  142.     end /* do until */
  143.  
  144. /* Now output sorted results after formatting a little */
  145. do index = 1 to area_names
  146.    select                                                               
  147.       when messages.index.count > 9999 then                             
  148.          m_txt = space(messages.index,                                  
  149.             trunc(messages.index.count),(22-length(messages.index)),'.')
  150.       when messages.index.count > 999 then                              
  151.          m_txt = space(messages.index,                                  
  152.             trunc(messages.index.count),(23-length(messages.index)),'.')
  153.       when messages.index.count > 99 then                               
  154.          m_txt = space(messages.index,                                  
  155.             trunc(messages.index.count),(24-length(messages.index)),'.')
  156.       when messages.index.count > 9 then                                
  157.          m_txt = space(messages.index,                                  
  158.             trunc(messages.index.count),(25-length(messages.index)),'.')
  159.       otherwise                                                         
  160.          m_txt = space(messages.index,                                  
  161.             trunc(messages.index.count),(26-length(messages.index)),'.')
  162.       end                                                               
  163.    call lineout out_name, m_txt
  164.    total_count = total_count + messages.index.count
  165.    end
  166.  
  167. m_txt = '  '
  168. call lineout out_name, m_txt
  169.  
  170. m_txt = space('Total' total_count,17,'.')
  171. call lineout out_name, m_txt
  172.  
  173. /* close files, return to starting directory, copy output to
  174. bulletin file */
  175. call lineout in_name
  176. call lineout out_name
  177. '@del lora.tmp'
  178. '@copy' out_name 'd:\lora\misc\BULLET7.BBS 1>NUL 2>&1'
  179. '@copy' out_name 'd:\lora\lang 1>NUL 2>&1'
  180. '@del eom.txt'
  181. call directory(old_dir)
  182.  
  183. /* the following really isn't necessary. Just curious how
  184. long it takes....*/
  185. time_spent = trunc( time('E'))             
  186. m_txt = ' '                                           
  187. if time_spent > 3599 then do               
  188.   hours = time_spent % 3600                
  189.   time_spent = time_spent - (3600 * hours) 
  190.   if hours > 1 then                        
  191.     m_txt = m_txt hours 'hours'            
  192.   else                                     
  193.     m_txt = m_txt hours 'hour'             
  194.   end                                      
  195.                                            
  196. if time_spent > 59 then do                 
  197.   minutes = time_spent % 60                
  198.   time_spent = time_spent - (60 * minutes) 
  199.   if minutes > 1 then                      
  200.     m_txt = m_txt minutes 'minutes'        
  201.   else                                     
  202.     m_txt = m_txt minutes 'minute'         
  203.   end                                      
  204.                                            
  205. if time_spent > 1 then                     
  206.   m_txt = m_txt time_spent 'seconds.'      
  207. else                                       
  208.   m_txt = m_txt time_spent 'second.'
  209.  
  210. say 'Done! ' m_txt                                    
  211.