home *** CD-ROM | disk | FTP | other *** search
- /* phyzlett.rexx */
-
- arg type host
-
- call MenuWindow(MYHOST,LETTERPORT)
-
- /* default parameters */
-
-
- bin = "81"
- date = "Automatic"
- addressee = "Jack the Ripper"
- address.1 = "12 Hyde Park"
- address.2 = ""
- address.3 = ""
- address.4 = ""
- cityzip = "London, England"
- salutation= "Dear Jake,"
- close = "Sincerely yours,"
- signature= "Marvin Weinstein"
- copies= "No"
- filename= "vd0:letter.tex"
- /* define screen text */
- text = ""
- text = text||"\"||copies(' ',51)||"Bin :\\"
- text = text||copies(' ',51)||"Date:\\"
- text = text||" Addressee:\\ Address:\\ :\\ :\\ :\\"
- text = text||" City-Zip:\\\ Salutation:\\\\\\"
- text = text||" To change an entry fill in the desired text\"
- text = text||" in the available space and then hit RETURN \"
- text = text||" When you are finished CLICK on the CONTINUE gadget\"
- text = text||"\\\\\ Close:\\ Signature:\\ Copies:\\ Filename:\\"
-
- quitflag = 0
-
- /* set up the gadgets */
- call WindowText(MYHOST,text)
-
- call AddGadget(MYHOST,480,21,"BIN",bin,"%d%1%g",180)
- call AddGadget(MYHOST,480,40,"DATE",date,"%d%1%g",180)
- call AddGadget(MYHOST,120,63,"ADDRESSEE",addressee,"%d%1%g",280)
- call AddGadget(MYHOST,120,81,"ADDRESS1",address.1,"%d%1%g",280)
- call AddGadget(MYHOST,120,99,"ADDRESS2",address.2,"%d%1%g",280)
- call AddGadget(MYHOST,120,117,"ADDRESS3",address.3,"%d%1%g",280)
- call AddGadget(MYHOST,120,135,"ADDRESS4",address.4,"%d%1%g",280)
- call AddGadget(MYHOST,120,153,"CITYZIP",cityzip,"%d%1%g",280)
- call AddGadget(MYHOST,120,180,"SALUTATION",salutation,"%d%1%g",280)
-
- call AddGadget(MYHOST,120,304,"CLOSE",close,"%d%1%g",260)
- call AddGadget(MYHOST,120,322,"SIGNATURE",signature,"%d%1%g",260)
- call AddGadget(MYHOST,120,340,"COPIES",copies,"%d%1%g",260)
- call AddGadget(MYHOST,120,358,"FILENAME",filename,"%d%1%g",260)
-
- call AddGadget(MYHOST,480,365,"CONTINUE","\ CONTINUE \","%d%1%d")
-
-
- do forever
- if quitflag = 1 then leave
- t = waitpkt(letterport)
- do ff = 1
- p = getpkt(letterport)
- if c2d(p) = 0 then leave ff
-
- command = getarg(p)
- t = reply(p, 0)
- select
- when command = CLOSEWINDOW then do
- call CloseWindow(MYHOST)
- quitflag = 1
- end
- when command = "CONTINUE" then do
- quitflag = 1
- call WriteTexFile(filename,type)
- call CloseWindow(MYHOST)
- end
- when command = "BIN" then call ActivateGadget(myhost,"DATE")
- when command = "DATE" then call ActivateGadget(myhost,"ADDRESSEE")
- when command = "ADDRESSEE" then call ActivateGadget(myhost,"ADDRESS1")
- when command = "ADDRESS1" then call ActivateGadget(myhost,"ADDRESS2")
- when command = "ADDRESS2" then call ActivateGadget(myhost,"ADDRESS3")
- when command = "ADDRESS3" then call ActivateGadget(myhost,"ADDRESS4")
- when command = "ADDRESS4" then call ActivateGadget(myhost,"CITYZIP")
- when command = "CITYZIP" then call ActivateGadget(myhost,"SALUTATION")
- when command = "SALUTATION" then call ActivateGadget(myhost,"CLOSE")
- when command = "CLOSE" then call ActivateGadget(myhost,"SIGNATURE")
- when command = "SIGNATURE" then call ActivateGadget(myhost,"COPIES")
- when command = "COPIES" then call ActivateGadget(myhost,"FILENAME")
- when command = "FILENAME" then call ActivateGadget(myhost,"BIN")
- otherwise say command
- end
-
- end
- end
-
- if host = "WB" then queue endcli
- exit
-
- /* MenuWindow.rexx - menu making function */
-
- MenuWindow:
-
- arg menuhost, menuport
-
- runwsh "'x=createhost("menuhost||","||menuport||")'"
- mp = openport(menuport)
- do i = 1 to 2
- address command 'c:WaitForPort 'menuhost
- address command 'c:WaitForPort 'menuport
- if RC=0 then leave i
- end
-
- idcmp = 'CLOSEWINDOW+GADGETUP'
- flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+BACKFILL'
-
- call OpenWindow(menuhost, 0, 0,screencols(),screenrows(), idcmp, flags)
-
- call setapen(menuhost,2)
- call setbpen(menuhost,1)
- call setdrmd(menuhost,JAM2)
-
- return 0
-
- /* GetVar.rexx */
-
- GetVar:
- parse arg menuhost, menuport, gadgetname
- call ReadGadget(menuhost,gadgetname)
- t = waitpkt(menuport)
- p = getpkt(menuport)
- string = getarg(p,1)
- t = reply(p,0)
- string = strip(string)
- return string
-
- /* this writes the given tex file */
-
- WriteTexFile:
-
- arg filename, type
-
- bin = GetVar(MYHOST,LETTERPORT,"BIN")
- date = GetVar(MYHOST,LETTERPORT,"DATE")
- addressee = GetVar(MYHOST,LETTERPORT,"ADDRESSEE")
- address.1 = GetVar(MYHOST,LETTERPORT,"ADDRESS1")
- address.2 = GetVar(MYHOST,LETTERPORT,"ADDRESS2")
- address.3 = GetVar(MYHOST,LETTERPORT,"ADDRESS3")
- address.4 = GetVar(MYHOST,LETTERPORT,"ADDRESS4")
- address.5 = GetVar(MYHOST,LETTERPORT,"CITYZIP")
- salutation = GetVar(MYHOST,LETTERPORT,"SALUTATION")
- close = GetVar(MYHOST,LETTERPORT,"CLOSE")
- signature = GetVar(MYHOST,LETTERPORT,"SIGNATURE")
- copies = GetVar(MYHOST,LETTERPORT,"COPIES")
- filename = GetVar(MYHOST,LETTERPORT,"FILENAME")
-
- /* check to see if the file already exists */
- do outer = 1
- if ~exists(filename) then leave outer
- else do
- string = "FILE" filename "ALREADY EXISTS.\"
- string = string||"TO REPLACE CLICK ON REP\"
- string = string||"HIT QUIT IF YOU WANT OUT OF THIS EXEC"
- ans = request(200,200,string,,"REP","QUIT",)
- end
-
- select
- when ans = "OKAY" then leave outer
- when ans = "" then do
- "set phyzlettinfo="
- return(3)
- end
- end
- end
-
-
- /* Erase previous file with this name */
-
- if exists(filename) then "delete "filename
-
- /* Now write the TeX file */
-
- checkfile = open(outfile, filename, 'W')
- if checkfile = 0 then do
- say "Couldn't open file for output"
- exit
- end
-
- call writeln outfile, '%macropackage=phyzzx'
-
- /* Following line is unique to new PHYZZX */
-
- call writeln outfile, '\def\binno{'bin'}'
-
- call writeln outfile, '\letters'
-
- if date ~= 'Automatic' then call writeln outfile, '\date{'date'}'
-
- if type = "SLAC" then call writeln outfile, '\letter{'addressee '\cr'
- else if type = "MY" then call writeln outfile, '\myletter{'addressee '\cr'
- else call writeln outfile, '\whoseletter{'addressee '\cr'
- call writeln outfile, address.1 '\cr'
-
- if address.2 ~= "" then call writeln outfile, address.2 '\cr'
- if address.3 ~= "" then call writeln outfile, address.3 '\cr'
- if address.4 ~= "" then call writeln outfile, address.4 '\cr'
-
-
- if cityzip ~= "" then call writeln outfile, cityzip '\cr '
- call writeln outfile, '}'
-
-
-
- call writeln outfile, salutation
- call writeln outfile, ' '
- call writeln outfile, '%letterbody%'
- call writeln outfile, ' '
- call writeln outfile, ' '
- call writeln outfile, ' '
- call writeln outfile, '\signed{ 'close' \cr'
- call writeln outfile, signature||' \cr}'
- call writeln outfile, ' '
-
- /* Check if there are to be copies */
-
- if copies ~= 'No' then do
- call writeln outfile, ' '
- call writeln outfile, '\copies %This is to be
- followed by the list of people to whom you wish'
- call writeln outfile, '% copies to be sent. To get
- one name to a line type NAME \nextline'
- call writeln outfile, ' '
- call writeln outfile, ' '
- call writeln outfile, ' '
- end
-
- call writeln outfile, '\endletter'
- call writeln outfile, '\end'
- call close(outfile)
-
-
- /* Now EDIT the file */
-
- ' e' filename
- "set phyzlettinfo="
- call delay 150
-
- return(0)
-