home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / EDGE1_704.DMS / in.adf / Edge_Rexx.lha / EditUserVars.edge < prev    next >
Encoding:
Text File  |  1993-10-27  |  4.2 KB  |  180 lines

  1.  
  2. /*
  3. ** $VER: EditUserVars.edge 1.13 (Sunday 08-Aug-93 02:36:57)
  4. **
  5. ** View/edit the user variables in Edge.
  6. ** NOTE: needs rexxarplib.library v3.0
  7. **
  8. ** Written by Thomas liljetoft
  9. */
  10.  
  11.  
  12. options results
  13.  
  14. /* first get the argument */
  15.  
  16. parse arg type
  17. if upper(type) = GLOBAL then
  18. do
  19.     titlestr = "Edit global user variables."
  20.     id = "_GE_"
  21. end
  22. else
  23. do
  24.     titlestr = "Edit local user variables."
  25.     id = "_FE_"
  26. end
  27.  
  28. /* load 'rexxarplib.library' if not loaded */
  29. if ~show('l','rexxarplib.library') then
  30.     call addlib('rexxarplib.library',0,-30)
  31.  
  32. /* get screen environment data */
  33.  
  34. 'getenvvar' _ge_screenname
  35. screenname = result
  36. 'getenvvar' _ge_barheight
  37. barheight = result
  38. 'getenvvar' _ge_visualscreenheight
  39. screenheight = result
  40.  
  41. myportname = EDITUSERVARPORT||upper(device)
  42. myhostname = EDITUSERVARHOST||upper(device)
  43.  
  44. /* try to create a port */
  45.  
  46. myport = openport(myportname)
  47. if c2d(myport) == 0    then do
  48.     'requestnotify' title '"EditUserVars error"' "Couldn't open '"myportname"', am exiting"
  49.     exit(0)
  50.     end
  51.  
  52. /* try to create our rexxarp host */
  53.  
  54. address AREXX "'call createhost("myhostname","myportname","'"'screenname'"'")'"
  55. address command waitforport myhostname
  56. if ~showlist('p',myhostname) then do
  57.     'requestnotify' title '"EditUserVars error"' "Couldn't create '"myhostname"', am exiting"
  58.     exit(0)
  59.     end
  60.  
  61. /* setup window stuff, colors, idcmp, font, etc */
  62.  
  63. call setreqcolor(myhostname,SHADOW,1)
  64. call setreqcolor(myhostname,BOX,2)
  65. call setreqcolor(myhostname,OKAY,1)
  66.  
  67. idcmp = 'CLOSEWINDOW+GADGETUP+VANILLAKEY'
  68. flags = 'ACTIVATE+WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH'
  69.  
  70. window_w = 600
  71. window_h = 188+barheight
  72. if window_h + barheight > screenheight then
  73.     window_t = screenheight - window_h
  74. else
  75.     window_t = barheight
  76.  
  77. call openwindow(myhostname,20,window_t,window_w,window_h,idcmp,flags,titlestr)
  78. call setfont(myhostname,"topaz.font",8,0,1,8)
  79. call setapen(myhostname,1)
  80. call modifyhost(myhostname,VANILLAKEY,"%l %a")
  81.  
  82. /* get the user vars and attach each to a string gadget */
  83.  
  84. do i = 0 to 9
  85.     call move(myhostname,12,i*15+barheight+12)
  86.     call text(myhostname,id||"User"i)
  87.     'getenvvar' id||user||i
  88.     call AddGadget(myhostname,124,i*15+barheight+6,i,result,i||"%1%g",464,RIDGEBORDER)
  89.     end
  90.  
  91. /* add the Flag gadget */
  92.  
  93. call move(myhostname,12,150+barheight+12)
  94. call text(myhostname,id||"UserFlags")
  95. 'getenvvar' id||"userflags"
  96. call AddGadget(myhostname,124,150+barheight+6,10,result,10||"%1%g",464,RIDGEBORDER)
  97.  
  98. /* and the 'Ok' and 'Cancel' gadgets */
  99.  
  100. call addgadget(myhostname,12,window_h - 16,10,"   Ok   ","Ok")
  101. call addgadget(myhostname,window_w - 80,window_h - 16,10," Cancel ","Cancel")
  102.  
  103. /* main loop */
  104.  
  105. do forever
  106.  
  107.     if quitflag = 1 then leave
  108.  
  109.     call waitpkt(myportname)
  110.  
  111.     do inner_loop = 1
  112.     
  113.         pkt = getpkt(myportname)
  114.         if c2d(pkt) = 0 then leave inner_loop
  115.         command = getarg(pkt,0)
  116.         parse var command command value
  117.         call reply(pkt,0)
  118.  
  119.         select
  120.  
  121.             /* quit (cancel) by clicking 'Cancel', pressing 'c' or 'C' or 'ESC' */
  122.  
  123.             when (command = CLOSEWINDOW) | (command = VANILLAKEY & (value = '' | upper(value) = 'C')) | (command = "Cancel") then
  124.             do
  125.                 call closewindow(myhostname)
  126.                 quitflag = 1
  127.             end
  128.  
  129.             /* ok by clicking 'Ok' or pressing 'o' or 'O' */
  130.  
  131.             when (command = "Ok") | (command = VANILLAKEY & upper(value) = 'O') then
  132.             do
  133.                 do i = 0 to 10
  134.                     call readgadget(myhostname,i)
  135.                     do wait = 1
  136.                         call waitpkt(myportname)
  137.                         pkt = getpkt(myportname)
  138.                         if c2d(pkt) ~= 0 then
  139.                         do
  140.                             command = getarg(pkt,0)
  141.                             string = getarg(pkt,1)
  142.                             call reply(pkt,0)
  143.                             parse var command command 
  144.                             if command >= 0 & command <= 10 then
  145.                             do
  146.                                 if i = 10 then
  147.                                     'putenvvar' id||"userflags" '"'string'"'
  148.                                 else
  149.                                     'putenvvar' id||user||i '"'string'"'
  150.                                 leave wait
  151.                             end
  152.                         end    
  153.                     end
  154.                 end
  155.                 call closewindow(myhostname)
  156.                 quitflag = 1
  157.             end
  158.  
  159.             /* by pressng keys '0' to '9'  the user may activate the stringgadgets */
  160.  
  161.             when command = VANILLAKEY & value >=0 & value <= 9 then
  162.             do
  163.                 call activategadget(myhostname,strip(value))
  164.             end
  165.  
  166.             /* by pressng 'f' or 'F' the user may activate the flag stringgadget */
  167.  
  168.             when command = VANILLAKEY & upper(value) = 'F' then
  169.             do
  170.                 call activategadget(myhostname,10)
  171.             end
  172.             otherwise nop
  173.         end
  174.     end
  175. end
  176.  
  177. call closeport(myportname)
  178.  
  179. exit(0)
  180.