home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 633.lha / PrintFiles_v0.9 / English / Rexx / prf.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1992-04-16  |  2.0 KB  |  72 lines

  1. /* *************************************************** */
  2. /* printfiles Arexx Macro                              */
  3. /* © 1992 by K. Klingbeil                              */
  4. /* inserts files into the print list using AmigaDos    */
  5. /* pattern matching facilities                         */
  6. /* USAGE: rx prf -f<Arexx-Script> <insert> -r<remove>  */
  7. /* Example : rx prf -ftest.rexx #?test#? -rtest.h      */
  8. /* this examples inserts all files which contain       */
  9. /* the pattern  'test' info the print list, removes    */
  10. /* the file test.h and executes the Arexx-script       */
  11. /* test.rexx                                           */
  12. /* NOTE: Scripts that are generated from PrintFiles    */
  13. /* itself (Save button in the prefs window) contain    */
  14. /* a 'reset' command at the first line. You should     */
  15. /* call the prf macro with such a script as the first  */
  16. /* argument.                                           */
  17. /* *************************************************** */
  18.  
  19. options results
  20. address command 'rx prfstart'
  21. if result = 5 then exit
  22.  
  23. parse arg CmdLine
  24. p = words(CmdLine)
  25.  
  26. do i = 1 to p
  27.    pattern = word(CmdLine,i)
  28.    if left(pattern,2) == '-r' then removefile(substr(pattern,3))
  29.     else
  30.      if left(pattern,2) == '-f' then rxfile(substr(pattern,3))
  31.       else insertfile(pattern)
  32. end
  33. exit
  34.  
  35. rxfile: procedure
  36. parse arg template
  37. cmd =  'rx ' template
  38. address command cmd
  39. return 1
  40.  
  41. removefile: procedure
  42. parse arg template
  43. cmd =  'list >pipe:prf' template 'quick'
  44. address command cmd
  45. address printfiles
  46. open('p','pipe:prf','r')
  47.  do while ~eof('p')
  48.   file = readln('p')
  49.   a = subword(file,1,1)
  50.   b = subword(file,2,1)
  51.   if a ~== '' & b == '' then remfile a
  52.  end
  53. close('p')
  54.  
  55. return 1
  56.  
  57. insertfile: procedure
  58. parse arg template
  59. cmd =  'list >pipe:prf' template 'quick'
  60. address command cmd
  61. address printfiles
  62. open('p','pipe:prf','r')
  63.  do while ~eof('p')
  64.   file = readln('p')
  65.   a = subword(file,1,1)
  66.   b = subword(file,2,1)
  67.   if a ~== '' & b == '' then insfile a
  68.  end
  69. close('p')
  70. return  1
  71.  
  72.