home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / newfil11.zip / NEWPICKS.CMD < prev    next >
OS/2 REXX Batch file  |  1993-10-24  |  6KB  |  198 lines

  1. /* newpicks.cmd - displays files and their descriptions from ALLFILES.NEW
  2. that have been picked.  You may "pick" files by inserting a "`" character
  3. next to the files you desire.
  4.  
  5. Steve Allen
  6. Altech Computer Services
  7. 121 Herta St.
  8. Easley, SC 29640
  9.  
  10. Oct 93
  11. trace ?i
  12. */
  13.  
  14.     say ""
  15.     say "Newpicks v1.1 1993"
  16.     say "Altech Computer Services" 'fe'x "Steve Allen"
  17.     say ""
  18.  
  19.     arg ifile newfile /* the "newfile" is optional--has default value */
  20.  
  21.     call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  22.     call sysloadfuncs
  23.  
  24.  
  25.     if ifile = "" then
  26.         ifile       = "ALLFILES.NEW"    /* the name of the OS/2 shareware file */
  27.  
  28.     iline       = ""
  29.     oline       = ""
  30.     linecnt     = 0
  31.     newpicks_found = 0
  32.     char2find   = "`"
  33.  
  34.     if stream(ifile,'c',query exists) = "" then
  35.         do 
  36.             call beep_error
  37.             say ifile "not found.  Terminating program."
  38.             exit(5)
  39.         end
  40.  
  41.     parse var ifile ibase "." iext
  42.  
  43.     if newfile = "" then
  44.         ofile       = ibase".PIK"   /* the default output name */
  45.     else
  46.         ofile = newfile             /* the user's desired output name */
  47.  
  48.     if stream(ofile,'c',query exists) \= "" then
  49.         do 
  50.             rc = SysFileDelete(ofile)
  51.             if rc \= 0 then
  52.                 do
  53.                     call beep_error
  54.                     say "Could not delete" ofile".  Terminating program."
  55.                     exit(4)
  56.                 end
  57.         end
  58.  
  59.     backspace   = '08'x
  60.     odometer_msg = "Processing line number "
  61.     call charout , odometer_msg
  62.  
  63.  
  64. main:
  65. /*----------------------------------------------------------------------------*/
  66. /*  Read in all the lines in ALLFILES.NEW, printing the new files as you come */
  67. /*  across them.                                                              */
  68. /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---*/
  69.     call read_line
  70.     do while lines(ifile) > 0
  71.         call get_newpicks
  72.     end
  73.     call eoj
  74. exit
  75.  
  76.  
  77. get_newpicks:
  78. /*----------------------------------------------------------------------------*/
  79. /* If you come across a heading for a particular file section, save it.  You  */
  80. /* may use it later if you have any new files in that particular section.  If */
  81. /* you find a file (denoted by having a period within the first 12 characters)*/
  82. /* see if it's a new file.  If so, print it.  Otherwise, just read the next   */
  83. /* line.                                                                      */
  84. /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---*/
  85.         if substr(iline,1,1) = 'cd'x then
  86.             do
  87.                 printed_headings = 'N'
  88.                 do headnbr = 1 to 8
  89.                     headarray.headnbr = iline
  90.                     call read_line
  91.                 end
  92.             end
  93.  
  94.         if pos(".", substr(iline,1,12)) > 0 then
  95.             do
  96.                 if newfile() then
  97.                     call print_files_lines
  98.                 else
  99.                     call read_line
  100.             end
  101.         else
  102.             call read_line
  103. return
  104.  
  105.  
  106. newfile:
  107. /*----------------------------------------------------------------------------*/
  108. /*  if the files date is newer than the comparison date, indicate that you've */
  109. /*  found a new file.                                                         */
  110. /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---*/
  111.     retval = 0
  112.     if substr(iline,1,1) = char2find then
  113.         do 
  114.             retval = 1
  115.             newpicks_found = newpicks_found + 1
  116.             iline = substr(iline,2)
  117.         end
  118.  
  119. return retval
  120.  
  121.  
  122. print_files_lines:
  123. /*----------------------------------------------------------------------------*/
  124. /*  If you haven't printed the heading yet for this particular section in     */
  125. /*  which you've found the new file, then print it.  Then print all the       */
  126. /*  description lines for this new file.                                      */
  127. /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---*/
  128.     if printed_headings = 'N' then
  129.         do
  130.             printed_headings = 'Y'
  131.             do headnbr = 1 to 8
  132.                 call lineout ofile, headarray.headnbr
  133.             end
  134.         end
  135.  
  136.     oline = iline
  137.     call lineout ofile, oline
  138.     call read_line
  139.     do while substr(iline,1,1) =  ' ' & lines(ifile) > 0
  140.         oline = iline
  141.         call lineout ofile, oline
  142.         call read_line
  143.     end
  144. return
  145.  
  146.  
  147. read_line:
  148. /*----------------------------------------------------------------------------*/
  149. /*  read in a line, letting the user get an idea of how many lines have been  */
  150. /*  processed so far.                                                         */
  151. /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---*/
  152.     iline = linein(ifile)
  153.     linecnt = linecnt + 1
  154.  
  155.     if linecnt // 37 = 0 then
  156.         do
  157.             j = length(linecnt)
  158.             call charout ,linecnt
  159.             do k = 1 to j
  160.                 call charout, backspace
  161.             end
  162.         end
  163. return
  164.  
  165.  
  166. beep_error:
  167. /*----------------------------------------------------------------------------*/
  168. /*  The big raspberry.                                                        */
  169. /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---*/
  170.     duration = 100
  171.     call beep 262, duration
  172.     call beep 330, duration
  173.     call beep 262, duration
  174. return
  175.  
  176.  
  177. eoj:
  178. /*----------------------------------------------------------------------------*/
  179. /*  That's all folks!                                                         */
  180. /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---*/
  181.     j = length(odometer_msg)
  182.     do k = 1 to j
  183.         call charout, backspace
  184.     end
  185.  
  186.     call lineout ofile
  187.  
  188.     say copies(" ",60)
  189.     say "Output is" ofile"."
  190.     say linecnt "lines processed."
  191.     say newpicks_found "new files found."
  192.     say " "
  193.     exit
  194. return
  195.  
  196. /* end of newpicks.cmd */
  197.  
  198.