home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / system / printfiles / deutsch / beispiele / pattern.rexx < prev    next >
OS/2 REXX Batch file  |  1995-02-27  |  2KB  |  63 lines

  1. /* printfiles Arexx Macro                              */
  2. /* © 1992 by K. Klingbeil                              */
  3. /* fügt Dateinamen mittels pattern-matching in die     */
  4. /* Druckliste ein                                      */
  5. /* Befehl   : rx pattern [Einfügepattern] -r[Löschpattern] */
  6. /* Beispiel : rx pattern  #?.c #?.h -rtest#?.c  -rtest.h   */
  7. /*            fügt alle Dateien im aktuellen           */
  8. /*            Verzeichnis, die auf .c oder .h enden in */
  9. /*            die Druckliste und löscht alle dateien   */
  10. /*            die test im Namen mit der Endung .c      */
  11. /*            und die Datei test.h                     */
  12.  
  13. options results   /* Ergebnisse anfordern */
  14. if ~show(ports,'PRINTFILES')then do   /* Läuft PrintFiles schon ? */
  15.     address command 'printfiles'   /* wenn nicht, dann ein Startversuch */
  16. address command 'sys:rexxc/WaitForPort PRINTFILES'  /* noch ein bisschen abwarten */
  17. end   /* Noch'n Versuch */
  18. if ~(show(ports,'PRINTFILES')) then return 5   /* Rückgabewert 5 bei Mißerfolg */
  19.  
  20.  
  21. parse arg CmdLine
  22. p = words(CmdLine)
  23.  
  24. do i = 1 to p
  25.    pattern = word(CmdLine,i)
  26.    if left(pattern,2) == '-r' then removefile(substr(pattern,3))
  27.    else insertfile(pattern)
  28. end
  29. address printfiles 'print'
  30. exit
  31.  
  32. rxfile: procedure
  33. parse arg template
  34. cmd =  'rx ' template
  35. address command cmd
  36. return 1
  37.  
  38. removefile: procedure
  39. parse arg template
  40. cmd =  'list >pipe:prf' template 'LFORMAT "%P%N" quick'
  41. address command cmd
  42. open('p','pipe:prf','r')
  43.  do while ~eof('p')
  44.   file = readln('p')
  45.   if file ~== '' then address printfiles remfile ''file
  46.  end
  47. close('p')
  48.  
  49. return 1
  50.  
  51. insertfile: procedure
  52. parse arg template
  53. cmd =  'list >pipe:prf' template 'LFORMAT "%P%N" quick'
  54. address command cmd
  55. open('p','pipe:prf','read')
  56.  do while ~eof('p')
  57.   file = readln('p')
  58.   if file ~== '' then address printfiles insfile ''file
  59.  end
  60. close('p')
  61. return  1
  62.  
  63.