home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 216.lha / RexxArpLib_v2.1 / rexx / PHYZStuff / phyzlett.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1996-02-15  |  7.6 KB  |  247 lines

  1. /* phyzlett.rexx */
  2.  
  3. arg type host
  4.  
  5.    call MenuWindow(MYHOST,LETTERPORT)
  6.  
  7. /* default parameters */
  8.  
  9.  
  10.     bin = "81"
  11.     date = "Automatic"
  12.         addressee = "Jack the Ripper"
  13.         address.1 = "12 Hyde Park"
  14.         address.2 = ""
  15.         address.3 = ""
  16.         address.4 = ""
  17.         cityzip = "London, England"
  18.         salutation= "Dear Jake,"
  19.         close = "Sincerely yours,"
  20.         signature= "Marvin Weinstein"
  21.         copies= "No"
  22.         filename= "vd0:letter.tex"
  23. /* define screen text */
  24.    text = ""
  25.    text = text||"\"||copies(' ',51)||"Bin :\\"
  26.    text = text||copies(' ',51)||"Date:\\"
  27.    text = text||"  Addressee:\\    Address:\\           :\\           :\\           :\\"
  28.    text = text||"   City-Zip:\\\ Salutation:\\\\\\"
  29.    text = text||"             To change an entry fill in the desired text\"
  30.    text = text||"             in the available space and then hit RETURN \"
  31.    text = text||"             When you are finished CLICK on the CONTINUE gadget\"
  32.    text = text||"\\\\\      Close:\\  Signature:\\     Copies:\\   Filename:\\"
  33.  
  34.    quitflag = 0
  35.  
  36. /* set up the gadgets */
  37.    call WindowText(MYHOST,text)
  38.  
  39.    call AddGadget(MYHOST,480,21,"BIN",bin,"%d%1%g",180)
  40.    call AddGadget(MYHOST,480,40,"DATE",date,"%d%1%g",180)
  41.    call AddGadget(MYHOST,120,63,"ADDRESSEE",addressee,"%d%1%g",280)
  42.    call AddGadget(MYHOST,120,81,"ADDRESS1",address.1,"%d%1%g",280)
  43.    call AddGadget(MYHOST,120,99,"ADDRESS2",address.2,"%d%1%g",280)
  44.    call AddGadget(MYHOST,120,117,"ADDRESS3",address.3,"%d%1%g",280)
  45.    call AddGadget(MYHOST,120,135,"ADDRESS4",address.4,"%d%1%g",280)
  46.    call AddGadget(MYHOST,120,153,"CITYZIP",cityzip,"%d%1%g",280)
  47.    call AddGadget(MYHOST,120,180,"SALUTATION",salutation,"%d%1%g",280)
  48.  
  49.    call AddGadget(MYHOST,120,304,"CLOSE",close,"%d%1%g",260)
  50.    call AddGadget(MYHOST,120,322,"SIGNATURE",signature,"%d%1%g",260)
  51.    call AddGadget(MYHOST,120,340,"COPIES",copies,"%d%1%g",260)
  52.    call AddGadget(MYHOST,120,358,"FILENAME",filename,"%d%1%g",260)
  53.    
  54.    call AddGadget(MYHOST,480,365,"CONTINUE","\  CONTINUE  \","%d%1%d")
  55.  
  56.  
  57. do forever
  58.    if quitflag = 1 then leave
  59.    t = waitpkt(letterport)
  60.    do ff = 1
  61.       p = getpkt(letterport)
  62.       if c2d(p) = 0 then leave ff
  63.       
  64.       command = getarg(p)
  65.       t = reply(p, 0)
  66.       select
  67.            when command = CLOSEWINDOW then do
  68.               call CloseWindow(MYHOST)
  69.               quitflag = 1
  70.            end
  71.            when command = "CONTINUE" then do
  72.               quitflag = 1
  73.              call WriteTexFile(filename,type)
  74.              call CloseWindow(MYHOST)
  75.            end
  76.            when command = "BIN" then call ActivateGadget(myhost,"DATE")
  77.            when command = "DATE" then call ActivateGadget(myhost,"ADDRESSEE")
  78.            when command = "ADDRESSEE" then call ActivateGadget(myhost,"ADDRESS1")
  79.            when command = "ADDRESS1"  then call ActivateGadget(myhost,"ADDRESS2")
  80.            when command = "ADDRESS2" then  call ActivateGadget(myhost,"ADDRESS3")
  81.            when command = "ADDRESS3" then  call ActivateGadget(myhost,"ADDRESS4")
  82.            when command = "ADDRESS4" then  call ActivateGadget(myhost,"CITYZIP")
  83.            when command = "CITYZIP" then   call ActivateGadget(myhost,"SALUTATION")
  84.            when command = "SALUTATION" then call ActivateGadget(myhost,"CLOSE")
  85.            when command = "CLOSE" then call ActivateGadget(myhost,"SIGNATURE")
  86.            when command = "SIGNATURE" then call ActivateGadget(myhost,"COPIES")
  87.            when command = "COPIES" then call ActivateGadget(myhost,"FILENAME")
  88.            when command = "FILENAME" then call ActivateGadget(myhost,"BIN")
  89.            otherwise say command 
  90.        end
  91.  
  92.    end
  93. end
  94.  
  95. if host = "WB" then queue endcli
  96. exit
  97.  
  98. /* MenuWindow.rexx - menu making function */
  99.  
  100. MenuWindow:
  101.  
  102. arg menuhost, menuport
  103.  
  104. runwsh  "'x=createhost("menuhost||","||menuport||")'"
  105. mp = openport(menuport)
  106. do i = 1 to 2
  107.   address command 'c:WaitForPort 'menuhost
  108.   address command 'c:WaitForPort 'menuport
  109.   if RC=0 then leave i
  110. end
  111.  
  112. idcmp = 'CLOSEWINDOW+GADGETUP'
  113. flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+BACKFILL'
  114.  
  115. call OpenWindow(menuhost, 0, 0,screencols(),screenrows(), idcmp, flags)
  116.  
  117.    call setapen(menuhost,2)
  118.    call setbpen(menuhost,1)
  119.    call setdrmd(menuhost,JAM2)
  120.  
  121. return 0
  122.  
  123. /* GetVar.rexx */
  124.  
  125. GetVar:
  126.   parse arg menuhost, menuport, gadgetname
  127.            call ReadGadget(menuhost,gadgetname)
  128.            t = waitpkt(menuport)
  129.            p = getpkt(menuport)
  130.            string = getarg(p,1)
  131.            t = reply(p,0)
  132.            string = strip(string)
  133. return string
  134.  
  135. /* this writes the given tex file */
  136.  
  137. WriteTexFile:
  138.  
  139.    arg filename, type
  140.  
  141.            bin = GetVar(MYHOST,LETTERPORT,"BIN")
  142.            date = GetVar(MYHOST,LETTERPORT,"DATE")
  143.            addressee = GetVar(MYHOST,LETTERPORT,"ADDRESSEE")
  144.            address.1 = GetVar(MYHOST,LETTERPORT,"ADDRESS1")
  145.            address.2 = GetVar(MYHOST,LETTERPORT,"ADDRESS2")
  146.            address.3 = GetVar(MYHOST,LETTERPORT,"ADDRESS3")
  147.            address.4 = GetVar(MYHOST,LETTERPORT,"ADDRESS4")
  148.            address.5 = GetVar(MYHOST,LETTERPORT,"CITYZIP")
  149.            salutation = GetVar(MYHOST,LETTERPORT,"SALUTATION")
  150.            close = GetVar(MYHOST,LETTERPORT,"CLOSE")
  151.            signature = GetVar(MYHOST,LETTERPORT,"SIGNATURE")
  152.            copies = GetVar(MYHOST,LETTERPORT,"COPIES")
  153.            filename = GetVar(MYHOST,LETTERPORT,"FILENAME")
  154.  
  155.  /* check to see if the file already exists */
  156.  do outer = 1
  157.    if ~exists(filename) then leave outer
  158.    else do
  159.     string = "FILE" filename "ALREADY EXISTS.\"
  160.     string = string||"TO REPLACE CLICK ON REP\"
  161.     string = string||"HIT QUIT IF YOU WANT OUT OF THIS EXEC"
  162.     ans = request(200,200,string,,"REP","QUIT",)
  163.    end
  164.  
  165.    select
  166.       when ans = "OKAY" then leave outer
  167.       when ans = "" then do
  168.          "set phyzlettinfo=" 
  169.          return(3)
  170.       end
  171.    end
  172.  end   
  173.  
  174.  
  175. /* Erase previous file with this name */
  176.  
  177.    if exists(filename) then "delete "filename
  178.  
  179. /* Now write the TeX file */
  180.  
  181.   checkfile = open(outfile, filename, 'W')
  182.   if checkfile = 0 then do
  183.      say "Couldn't open file for output"
  184.      exit
  185.   end
  186.  
  187.   call writeln outfile, '%macropackage=phyzzx'
  188.  
  189. /* Following line is unique to new PHYZZX  */
  190.  
  191.    call writeln outfile, '\def\binno{'bin'}'
  192.  
  193.    call writeln outfile, '\letters'
  194.    
  195.    if date ~= 'Automatic' then call writeln outfile,  '\date{'date'}'
  196.  
  197.    if type = "SLAC" then call writeln outfile,  '\letter{'addressee '\cr'
  198.    else if type = "MY" then call writeln outfile,  '\myletter{'addressee '\cr'
  199.    else call writeln outfile, '\whoseletter{'addressee '\cr'
  200.    call writeln outfile, address.1 '\cr'
  201.  
  202.    if address.2 ~= "" then call writeln outfile, address.2 '\cr'
  203.    if address.3 ~= "" then call writeln outfile, address.3 '\cr'
  204.    if address.4 ~= "" then call writeln outfile, address.4 '\cr'
  205.  
  206.  
  207.    if cityzip ~= "" then call writeln outfile, cityzip '\cr '
  208.    call writeln outfile, '}'
  209.  
  210.  
  211.  
  212. call writeln outfile, salutation
  213. call writeln outfile, '    '
  214. call writeln outfile, '%letterbody%'
  215. call writeln outfile, '    '
  216. call writeln outfile, '    '
  217. call writeln outfile, '    '
  218. call writeln outfile, '\signed{ 'close' \cr'
  219. call writeln outfile, signature||' \cr}'
  220. call writeln outfile, '    '
  221.  
  222. /* Check if there are to be copies */
  223.  
  224. if copies ~= 'No' then  do
  225.   call writeln outfile, '    '
  226.   call writeln outfile, '\copies  %This is to be
  227.   followed by the list of people to whom you wish'
  228.   call writeln outfile, '% copies to be sent.  To get
  229.   one name to a line type NAME \nextline'
  230.   call writeln outfile, '            '
  231.   call writeln outfile, '            '
  232.   call writeln outfile, '            '
  233. end
  234.  
  235. call writeln outfile, '\endletter'
  236. call writeln outfile, '\end'
  237. call close(outfile)
  238.  
  239.  
  240. /* Now EDIT the file */
  241.  
  242.  ' e' filename 
  243.  "set phyzlettinfo="
  244.   call delay 150
  245.  
  246. return(0)
  247.