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

  1. /* NODELIST.CMD - Looks for new nodediff and/or os2list
  2. files in their respective directories. If found, unzips and
  3. does a force compile for Lora and GoldED.
  4. Version 1.1 - 25 June 1994 by Elliott Goodman 
  5.  
  6. Donations for this program may be sent to:
  7.  
  8.      Elliott Goodman        
  9.      PO Box 500038          
  10.      Palmdale, CA 93591-0038
  11. */
  12.  
  13. /* check if RxFuncs are loaded. If not, loads */
  14. if RxFuncQuery('SysLoadFuncs') then
  15. do
  16.   call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  17.   call SysLoadFuncs
  18.   end
  19.  
  20. /* TRACE ?A */     /* uncomment to see what's going on! */
  21.  
  22. /* point to text file for messages */
  23. sav_file = 'd:\lora\lang\nodecmd.txt'
  24.  
  25. /* set up directories and filenames */
  26. area.1 = 'd:\lora\file\os2diff' ; file.1 = 'os2list.*'
  27. area.2 = 'd:\lora\file\nodediff' ; file.2 = 'nodediff.*'
  28.  
  29. /* initialize a couple of flags */
  30. flag.1 = 0 ; flag.2 = 0
  31.  
  32. /* main routine to look in each specified directory */
  33. do i = 1 to 2
  34.   newdir = area.i
  35.   f_name = file.i
  36.   call directory newdir
  37.   
  38.   /* used later to remove leading drive/directory info */
  39.   pattern = newdir||'\'
  40.   
  41.   /* converts to uppercase */
  42.   pattern = translate(pattern)
  43.   
  44.   /* initialize variable to find newest file */
  45.   maxage = 0
  46.  
  47.   /* form an array of names meeting filespec f_name */
  48.   call SysFileTree f_name, 'tfile' , 'F'
  49.   
  50.   /* the point: if more than one diff file is found,
  51.   a new one must have been tic'd there. */
  52.   if tfile.0 > 1 then
  53.   do
  54.     /* set flag for later use */
  55.     flag.i = 1
  56.  
  57.     /* find which file is the newest */
  58.     call get_new
  59.  
  60.     /* delete older ones */
  61.     call del_old
  62.  
  63.     /* update files.bbs after saving to files.bak */
  64.     call fix_files
  65.     end /* if tfile.0 > 1 */
  66.   end /* main do i = 1 to 2 loop */
  67.  
  68. /* if we processed os2list... */
  69. if flag.1 = 1 then
  70. do
  71.   /* get rid of older os2list */
  72.   'del d:\lora\nodes\os2list.*'
  73.  
  74.   /* copy new os2list here for processing */
  75.   'cd \lora\lang'
  76.   'copy d:\lora\file\os2diff\os2list.* d:\lora\lang'
  77.  
  78.   /* rename to zip so infozip will process without having
  79.   to know the exact filename */
  80.   'ren os2list.* os2list.zip'
  81.   
  82.   'unzip os2list'
  83.  
  84.   /* clean up as we go along */
  85.   'del os2list.zip'
  86.  
  87.   /* see if things have worked so far, ie., a
  88.   os2list.xxx file is present */
  89.   call SysFileTree file.1, 'tfile' , 'F'
  90.  
  91.   /* if not, notify and skip further processing */
  92.   if tfile.0 = 0 then
  93.   do
  94.     m_txt = 'Error with os2list'
  95.     call lineout sav_file, m_txt
  96.     end
  97.  
  98.   /* else continue processing */
  99.   else do
  100.     /* move */
  101.     'copy os2list.* d:\lora\nodes'
  102.     'del os2list.*'
  103.     end
  104.   end
  105.  
  106. if flag.2 = 1 then
  107. do
  108.   'cd \lora\lang'
  109.   'copy d:\lora\file\nodediff\nodediff.* d:\lora\lang'
  110.   'ren nodediff.* nodediff.arc'
  111.   'd:\lora\arce nodediff nodediff.* d:\lora\nodes /R'
  112.   'del nodediff.arc'
  113.   end
  114.  
  115. if flag.1 = 1 | flag.2 = 1 then do
  116.   'cd \lora'
  117.   'lora nodelist'
  118.   'cd \lora\golded'
  119.   'gn2 -f'
  120.   'e:\util\gamma2\hpfsopt d: -u'
  121.   end
  122. exit
  123.  
  124. /* subroutines follow */
  125.  
  126. get_new:
  127. do k=1 to tfile.0
  128.   parse upper var tfile.k month '/' day '/' year,
  129.         hour size attrib name
  130.   tfile.k.age = (month * 30) + day + (year * 10)
  131.   if tfile.k.age > maxage then
  132.     maxage = tfile.k.age
  133.   end
  134. return
  135.  
  136. del_old:
  137. do k=1 to tfile.0
  138.   parse upper var tfile.k date hour size attrib name
  139.   name = strip(name)
  140.   if tfile.k.age < maxage then do
  141.     parse upper var name (pattern) name
  142.     name = translate(name)
  143.     call SysFileDelete name
  144.     end
  145.   end
  146. return
  147.  
  148. fix_files:
  149. 'del files.bak'
  150. lineno = 1
  151. out_name = 'FILES.BAK'
  152. in_name = 'FILES.BBS'
  153. do until lines(in_name) = 0
  154.   bbs.lineno = linein(in_name)
  155.   call lineout out_name, bbs.lineno
  156.   lineno = lineno + 1
  157.   end
  158. lineno = lineno - 1
  159. call lineout in_name
  160. call lineout out_name
  161. 'del files.bbs'
  162. call lineout in_name, bbs.lineno
  163. call lineout in_name
  164. return
  165.  
  166.