home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / system / printfiles / english / example / circular.rexx < prev    next >
OS/2 REXX Batch file  |  1995-02-27  |  4KB  |  94 lines

  1. /* printfiles Arexx Macro                              */
  2. /* © 1992 by K. Klingbeil                              */
  3. /* builds circular letters out of a template letter    */
  4. /* and a address file                                  */
  5. /* Usage:  rx circular <template> <addresses>          */
  6. /* IMPORTANT: type the FULL filenames (including path) */
  7. /*            for <template> and <addresses>           */
  8. /* in this example (and with this disk) the pathnames  */
  9. /* would be :                                          */
  10. /* printfiles:printfiles/english/example/template.letter */
  11. /* printfiles:printfiles/english/example/names.dat     */
  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. parse arg argumente
  21.  
  22. letter = subword(argumente,1,1)
  23. names  = subword(argumente,2,1)
  24.  
  25. if  letter == '' then
  26. do
  27.   say 'template filename missing'
  28.   exit
  29. end
  30.  
  31. if  names == ''  then
  32. do
  33.   say 'address filename missing'
  34.   exit
  35. end
  36.  
  37. port = "TESTPORT"
  38.  
  39. if  ~Show('L',"rexxsupport.library")
  40. then do
  41.      addlib('rexxsupport.library',0,-30,0)
  42.      end                                      
  43.  
  44. if Show('L',"rexxsuport.library") then exit
  45. if OpenPort(port)                                  
  46.    then do
  47.           address printfiles 'replyport TESTPORT' 
  48.                                                   
  49.           address printfiles 'replace on'        
  50.           address printfiles 'ff on'             
  51.           open('p',names,'r')                    
  52.           do while ~eof('p')
  53.               name    = readln('p')
  54.               street  = readln('p')
  55.               town    = readln('p') 
  56.               if eof('p')           
  57.               then do
  58.                address printfiles 'removereplace firstname'      
  59.                address printfiles 'removereplace famname'
  60.                address printfiles 'removereplace street'
  61.                address printfiles 'removereplace town'
  62.                address printfiles 'removereplace mrmss'
  63.                ClosePort(port)                        
  64.                exit                                   
  65.               end
  66.               mrmss     = subword(name,1,1)            
  67.               firstname = subword(name,2,1)
  68.               famname   = subword(name,3,1)
  69.               address printfiles 'removereplace firstname'      
  70.               address printfiles 'removereplace famname'
  71.               address printfiles 'removereplace street'
  72.               address printfiles 'removereplace town'
  73.               address printfiles 'removereplace mrmss'
  74.               dv = 'firstname' firstname
  75.               dn = 'famname' famname
  76.               mr = 'mrmss' mrmss
  77.               st   = 'street' street
  78.               ot   = 'town' town
  79.               address printfiles insertreplace dv   
  80.               address printfiles insertreplace dn   
  81.               address printfiles insertreplace st
  82.               address printfiles insertreplace ot
  83.               address printfiles insertreplace mr
  84.               address printfiles insfile ''letter   
  85.                                                     
  86.               address printfiles 'print'            
  87.               WaitPkt(port)                         
  88.                                                     
  89.               p = Getpkt(port);                     
  90.               Reply(p,0)                            
  91.           end
  92.  
  93.      end
  94.