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

  1. /* phyzmemo.rexx */
  2.  
  3. arg host
  4.  
  5.  
  6. /* Define default values of parameters */
  7.    date = "Automatic"
  8.    to  = "John Doe"
  9.    from = "Jane Doe"
  10.    topic.1 = "Axiomatic love theory"
  11.    topic.2 = ""
  12.    topic.3 = ''
  13.    topic.4 = ''
  14.    topic.5 = ''
  15.    topic.6 = ''
  16.    topic.7 = ''
  17.    copies = "no"
  18.    filename = "vd0:memo.tex"
  19.  
  20. /* set up gadgets */
  21.  
  22.    text = "\\"||copies(' ',51)||"Date:\\\\        To:\\      From:\\     Topic:\\\\\\\\\\\\\"
  23.    text =text||"\\\             To change an entry fill in the desired text\"
  24.    text =text||"             in the available space and then hit RETURN \"
  25.    text =text||"             When you are finished CLICK on the CONTINUE gadget\\\"
  26.    text =text||"\\    Copies:\\  Filename:\\"
  27.  
  28.    call MenuWindow(MYHOST,MEMOPORT)
  29.  
  30.    call WindowText(MYHOST,text)
  31.  
  32.    call AddGadget(MYHOST,480,37,"DATE",date,"%d%1%g",180)
  33.    call AddGadget(MYHOST,120,69,"TO",to,"%d%1%g",280)
  34.    call AddGadget(MYHOST,120,88,"FROM",from,"%d%1%g",280)
  35.    call AddGadget(MYHOST,120,107,"TOPIC1",topic.1,"%d%1%g",400)
  36.    call AddGadget(MYHOST,120,126,"TOPIC2",topic.2,"%d%1%g",400)
  37.    call AddGadget(MYHOST,120,145,"TOPIC3",topic.3,"%d%1%g",400)
  38.    call AddGadget(MYHOST,120,164,"TOPIC4",topic.4,"%d%1%g",400)
  39.    call AddGadget(MYHOST,120,183,"TOPIC5",topic.5,"%d%1%g",400)
  40.    call AddGadget(MYHOST,120,202,"TOPIC6",topic.6,"%d%1%g",400)
  41.    call AddGadget(MYHOST,120,221,"TOPIC7",topic.7,"%d%1%g",400)
  42.  
  43.    call AddGadget(MYHOST,120,315,"COPIES",copies,"%d%1%g",180)
  44.    call AddGadget(MYHOST,120,334,"FILENAME",filename,"%d%1%g",260)
  45.  
  46.    call AddGadget(MYHOST,480,338,"CONTINUE","\  CONTINUE  \","%d%1%d")
  47.  
  48. quitflag = 0
  49.  
  50. do forever
  51.    if quitflag = 1 then leave
  52.    t = waitpkt(MEMOPORT)
  53.    do ff = 1
  54.       p = getpkt(MEMOPORT)
  55.       if c2d(p) = 0 then leave ff
  56.       
  57.       arg = getarg(p)
  58.       t = reply(p, 0)
  59.       parse var arg command string
  60.       select
  61.            when command = CLOSEWINDOW then do
  62.              call CloseWindow(MYHOST)
  63.              quitflag = 1
  64.            end
  65.            when command = "CONTINUE" then do
  66.               quitflag = 1
  67.              call WriteTexFile(filename)
  68.              call CloseWindow(MYHOST)
  69.            end
  70.            when command = "DATE" then call ActivateGadget(myhost,"TO")
  71.            when command = "TO" then call ActivateGadget(myhost,"FROM")
  72.            when command = "FROM" then call ActivateGadget(myhost,"TOPIC1")
  73.            when command = "TOPIC1"  then call ActivateGadget(myhost,"TOPIC2")
  74.            when command = "TOPIC2" then  call ActivateGadget(myhost,"TOPIC3")
  75.            when command = "TOPIC3" then  call ActivateGadget(myhost,"TOPIC4")
  76.            when command = "TOPIC4" then  call ActivateGadget(myhost,"TOPIC5")
  77.            when command = "TOPIC5" then  call ActivateGadget(myhost,"TOPIC6")
  78.            when command = "TOPIC6" then  call ActivateGadget(myhost,"TOPIC7")
  79.            when command = "TOPIC7" then  call ActivateGadget(myhost,"COPIES")
  80.            when command = "COPIES" then   call ActivateGadget(myhost,"FILENAME")
  81.            when command = "FILENAME" then call ActivateGadget(myhost,"DATE")
  82.            otherwise say command 
  83.       end
  84.    end /* ends ff */
  85. end  /* ends do forever */
  86. if host = "WB" then queue endcli
  87. exit
  88.  
  89. /* MenuWindow.rexx - menu making function */
  90.  
  91. MenuWindow:
  92.  
  93. arg menuhost, menuport
  94. runwsh "'x=createhost("menuhost||","||menuport||")'"
  95. mp = openport(menuport)
  96.  
  97. do i = 1 to 2
  98.   address command 'c:WaitForPort 'menuport
  99.   if RC=0 then leave i
  100. end
  101.  
  102. idcmp = 'CLOSEWINDOW+GADGETUP'
  103. flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+BACKFILL'
  104.  
  105. call OpenWindow(menuhost, 0, 0,screencols(),screenrows(), idcmp, flags)
  106.  
  107.    call setapen(menuhost,2)
  108.    call setbpen(menuhost,1)
  109.    call setdrmd(menuhost,JAM2)
  110.  
  111. return 0
  112.  
  113. /* GetVar.rexx */
  114.  
  115. GetVar:
  116.   parse arg menuhost, menuport, gadgetname
  117.            call ReadGadget(menuhost,gadgetname)
  118.            t = waitpkt(menuport)
  119.            p = getpkt(menuport)
  120.            string = getarg(p,1)
  121.            t = reply(p,0)
  122.            string = strip(string)
  123. return string
  124.  
  125.  
  126. WriteTexFile:
  127.    arg filename
  128.  
  129.       date = GetVar(MYHOST,MEMOPORT,"DATE")
  130.       to   = GetVar(MYHOST,MEMOPORT,"TO")
  131.       from = GetVar(MYHOST,MEMOPORT,"FROM")
  132.       topic.1 = GetVar(MYHOST,MEMOPORT,"TOPIC1")
  133.       topic.2 = GetVar(MYHOST,MEMOPORT,"TOPIC2")
  134.       topic.3 = GetVar(MYHOST,MEMOPORT,"TOPIC3")
  135.       topic.4 = GetVar(MYHOST,MEMOPORT,"TOPIC4")
  136.       topic.5 = GetVar(MYHOST,MEMOPORT,"TOPIC5")
  137.       topic.6 = GetVar(MYHOST,MEMOPORT,"TOPIC6")
  138.       topic.7 = GetVar(MYHOST,MEMOPORT,"TOPIC7")
  139.       copies = GetVar(MYHOST,MEMOPORT,"COPIES")
  140.       filename = GetVar(MYHOST,MEMOPORT,"FILENAME")
  141.  
  142.  /* check to see if the file already exists */
  143.  
  144.  do outer = 1
  145.    if ~exists(filename) then leave outer
  146.    else do
  147.     string = "FILE" filename "ALREADY EXISTS.\"
  148.     string = string||"TO REPLACE CLICK ON REP\"
  149.     string = string||"HIT QUIT IF YOU WANT OUT OF THIS EXEC"
  150.     ans = request(200,200,string,,"REP","QUIT",)
  151.    end
  152.  
  153.    select
  154.       when ans = "OKAY" then leave outer
  155.       when ans = "" then do
  156.          "set phyzmemoinfo=" 
  157.          return(3)
  158.       end
  159.    end
  160.  end   
  161.  
  162.  
  163. /* Erase previous file with this name */
  164.  
  165.    if exists(filename) then "delete "filename
  166.  
  167. /* Now write the TeX file */
  168.  
  169.   checkfile = open(outfile, filename, 'W')
  170.   if checkfile = 0 then do
  171.      say "Couldn't open file for output"
  172.      exit
  173.   end
  174.  
  175.   call writeln outfile, '%macropackage=phyzzx'
  176.  
  177. /* Following line is unique to new PHYZZX  */
  178.  
  179. if date ~= 'Automatic' then call writeln outfile,  '\date={'date'}'
  180. call writeln outfile, '\memo'
  181. call writeln outfile, '\to' to
  182. call writeln outfile, '\from' from
  183. call writeln outfile, '\topic' topic.1
  184.   if topic.2 ~= '' then call writeln outfile, topic.2
  185.   if topic.3 ~= '' then call writeln outfile, topic.3
  186.   if topic.4 ~= '' then call writeln outfile, topic.4
  187.   if topic.5 ~= '' then call writeln outfile, topic.5
  188.   if topic.6 ~= '' then call writeln outfile, topic.6
  189.   if topic.7 ~= '' then call writeln outfile, topic.7
  190. call writeln outfile, '     '
  191. call writeln outfile, '\rule '
  192. call writeln outfile, '     '
  193. call writeln outfile, '%memobody%'
  194. call writeln outfile, '     '
  195. call writeln outfile, '     '
  196.  
  197.  
  198. /* Check if there are to be copies */
  199.  
  200. if copies ~= 'no' then do
  201.   call writeln outfile, '     '
  202.   call writeln outfile, '\copies  %This is to be
  203.   followed by the list of people to whom you wish '
  204.   call writeln outfile, '% copies to be sent. To get
  205.   one name to a line type NAME \nextline'
  206.   call writeln outfile, '     '
  207.   call writeln outfile, '     '
  208.   call writeln outfile, '     '
  209.   call writeln outfile, '     '
  210. end
  211.  
  212. call writeln outfile, '\endpage'
  213. call writeln outfile, '\end'
  214. call close(outfile)
  215.  
  216.  
  217. /* Now XEDIT the file */
  218.  
  219. "e "filename
  220. "set phyzmemoinfo="
  221. call delay 150
  222.  
  223.