home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / mpbeta-2.zip / announce.cmd next >
OS/2 REXX Batch file  |  1994-07-12  |  7KB  |  213 lines

  1. /* ANNOUNCE.CMD - REXX program to generate a File Announcement
  2. with MPBeta for new files. Version 1.1
  3.  
  4. ver 1.1:  Found an error and in the process of cleaning it up, sped up the
  5. program's execution! Moved the file_desc stuff inside the loop.
  6.  
  7.   - 10 July, 1994 by Elliott Goodman, 1:102/1319 -
  8. */
  9.  
  10. /* check whether RxFuncs are loaded. If not, load them. */       
  11.                                                                  
  12. if RxFuncQuery('SysLoadFuncs') then                              
  13. do                                                               
  14.         call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  15.         call SysLoadFuncs                                        
  16. end                                                              
  17.  
  18. /* Just to let the user know what's going on.... */
  19.  
  20. say 'Searching thru file areas for new files to announce.'
  21. say 'Please wait....';
  22. say ' ';
  23.  
  24.  
  25. /* create a tracking file */
  26. report = 'd:\lora\file\mpbeta\announce.txt'
  27.  
  28. /* delete old tracking file, if present */
  29. call SysFileDelete(report)
  30.  
  31. m_txt = 'Report of ANNOUNCE.CMD activity'
  32. call lineout report, m_txt
  33. m_txt = ''
  34. call lineout report, m_txt
  35.  
  36. /* get today's date, create an index from it */
  37. day_index = SPECIFIED_DATE_IN_DAYS( DATE('U') )                        
  38.  
  39. /* set some defaults */
  40.  
  41. nfile.0 = 0
  42. files.0 = 0                /* will increment */
  43. file_index = 0
  44.  
  45. /* set up the array elements of FILES which will be used by
  46. MPM_AnnounceFiles() at the end of all this processing.
  47. See TANN.CMD included with MPBeta for details.   */
  48.  
  49. files.msgpath = 'D:\LORA\MSG\USERS'
  50. files.msgtype = 'SQUISH'
  51. files.msgflag = 'CRASH'
  52. files.to = 'ALL'
  53. files.toaddr = '1:102/1316.0'
  54. files.header = 'New files online at Miles Enterprises BBS'
  55. files.from = 'Elliott Goodman'
  56. files.fromaddr = '1:102/1319.0'
  57. files.footer = '- Elliott'
  58.  
  59. /* your origin info */
  60. files.origin = 'Miles Enterprises * 805-264-0200 *'
  61.  
  62. /* my first 44 areas are on the CD so I start with 44 (and increment it
  63. immediately.) This saves time since the CD is slow. */
  64. mpmarea = 44    
  65.  
  66. do forever                /* we'll bail out after the last area */
  67.    mpmarea = MPM_QueryArea(mpmarea)    /* look at next area */
  68.    if mpmarea = 'ERROR' then do
  69.       leave                /* this will bail us out */
  70.       end /* if error (past last file area) */
  71.  
  72. /* get drive/subdir of next file area */
  73.    area_path = MPM_QueryAreaInfo(mpmarea, '1')
  74.  
  75. /* notify user of our progress */
  76.    say area_path ;
  77.  
  78. /* use SysFileTree here to check for new files */
  79.    call SysFileTree area_path, stuff, 'F'
  80.  
  81. /* reset before each file area */
  82.    found_new = 0
  83.    nfile.0 = 0
  84.  
  85. /* assume at least one file in the file area */
  86.    do i = 1 to stuff.0        /* cycle thru files in one area */
  87.  
  88. /* get info on each file in the area */
  89.    parse var stuff.i,
  90.          file_date,
  91.          file_time,
  92.          file_size,
  93.          file_attr,
  94.          file_name
  95.  
  96. /* remove trailing space */
  97.    file_name = strip( file_name )
  98.  
  99. /* remove drive/subdir info from filename */
  100.    parse var file_name (area_path) file_name
  101.  
  102. /* convert to caps, just in case */
  103.    file_name = translate( file_name )
  104.  
  105. /* get extention. We don't want to announce FILES.BBS or FILES.BAK! */
  106.    parse var file_name junk '.' extn
  107.  
  108.    if extn = 'BAK' then do
  109.       iterate
  110.       end
  111.  
  112.    if extn = 'BBS' then do
  113.       iterate
  114.       end
  115.  
  116. /* test if next file is dated today, hence NEW */
  117.    file_test = SPECIFIED_DATE_IN_DAYS( file_date )
  118.    if file_test = day_index then do
  119.  
  120. /* here's where the ver. 1.1 code makes it's major changes. Store the
  121. files that are new and do them all at once for each area */
  122.       found_new = 1
  123.       nfile.0 = nfile.0 + 1
  124.       t_index = nfile.0
  125.       nfile.t_index = file_name
  126.       end /* if file_test = day_index */
  127.  
  128.    end /* do i = 1 to stuff.0 */
  129.  
  130. /* now, if we found one or more new files in this area... */
  131.    if found_new = 1 then do
  132.  
  133. /* we have to open the files.bbs file so we can get the
  134. description */
  135.       retval = MPM_OpenArea(mpmarea)
  136.  
  137. /* this just gives the system time to open the file */
  138.       Call SysSleep 3
  139.  
  140. /* ....cycle thru the new files for this area */
  141.       do k = 1 to nfile.0
  142.  
  143. /* continue storing elements in FILES */
  144.          file_index = file_index + 1
  145.          files.0 = files.0 + 1
  146.          files.file_index.path = area_path
  147.          files.file_index.file = nfile.k
  148.  
  149.          file_desc = MPM_QueryFileInfo(mpmarea, nfile.k, '3')
  150.          files.file_index.desc = file_desc
  151.          end /* do k to nfile.0 */
  152.  
  153. /* close the files.bbs file to avoid problems */
  154.       retval = MPM_CloseArea(mpmarea)
  155.       end /* if  found = 1 */
  156.  
  157.    end /* do forever */
  158.  
  159. /* if no new files: exit */
  160. if files.0 = 0 then do
  161.    m_txt = 'No new files found'
  162.    call lineout report, m_txt
  163.    exit
  164.    end
  165.  
  166. /* there are new files. Save the info so we can play
  167. with the descriptions when we wake up <g> */
  168.  
  169. m_txt = 'List of New Files'
  170. call lineout report, m_txt
  171. m_txt = ' '
  172. call lineout report, m_txt
  173.  
  174. do j = 1 to files.0
  175.    m_txt = 'File Path = ' files.j.path
  176.    call lineout report, m_txt
  177.    m_txt = 'File Name = ' files.j.file
  178.    call lineout report, m_txt
  179.    m_txt = 'File Description = ' files.j.desc
  180.    call lineout report, m_txt
  181.    m_txt = ' '
  182.    call lineout report, m_txt
  183.    end  
  184.  
  185. /* actually make the announcement */
  186. retval = MPM_AnnounceFiles('files')
  187.  
  188. m_txt = files.0 'new files announced!'
  189. call lineout report, m_txt
  190.  
  191. /* and we're done */
  192. exit
  193.  
  194. /*------------------------------------------------*/                 
  195. /* Convert calendar date to consistent date index                  */
  196. /*------------------------------------------------*/                 
  197. SPECIFIED_DATE_IN_DAYS:                                              
  198.    Procedure                                                         
  199.                                                                      
  200. parse arg,                                                           
  201.    mm '/',                                                           
  202.    dd '/',                                                           
  203.    yy                                                                
  204.                                                                      
  205. days_by_month = '31 28 31 30 31 30 31 31 30 31 30 31'                
  206. current_number_of_days = (yy * 365) + dd                             
  207. do m = 1 while m < mm                                                
  208.    current_number_of_days = current_number_of_days +,                
  209.       WORD( days_by_month, m )                                       
  210. end                                                                  
  211. return current_number_of_days                                        
  212.  
  213.