home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / uedit-stuff_429.lzh / Uedit-Stuff / AutoTraffic < prev    next >
Text File  |  1991-01-10  |  7KB  |  138 lines

  1.  
  2.                     PAUL'S UEDIT-AREXX INTERFACING STUFF
  3.  
  4. What we got here is a means of being able to have save-on-idle and rexx auto-
  5. traffic at the same time.  There's also a virtual key here which can take an
  6. incoming arexx message and interpret it as Uedit command language.
  7.  
  8.  
  9. COMBINING AUTO-TRAFFIC WITH SAVE-ON-IDLE:  It's kind of a kludge, but it
  10. works.  There are a couple of disadvantages relative to using either feature
  11. by itself:  You have to have a prekey (unless you want your idle save
  12. starting too soon half the time), and if you want to change the wait
  13. duration for idle saves you have to recompile the idle key instead of just
  14. using a command to set the idleTime variable (or you could change it to use
  15. an n-variable), and the actual duration you get is undependable.  See, you
  16. have to set the idleTime variable to 1 (a tenth of a second).  And the idle
  17. command counts tenths (which may actually last longer than 0.1 second; in
  18. fact it seems to count typically six to eight per second on a 16 bit amiga)
  19. until the number you want have gone by.  And you have to reset that counter,
  20. which is in n32 as written here, whenever there is input, so if you don't use
  21. a prekey, you have to use this one:
  22.  
  23. <prekey: equatenum(n32, 0) >
  24.  
  25. ... and if you have an existing prekey you have to add "equatenum(n32, 0)" to
  26. it at the top.
  27.  
  28. I originally used an idle time of 10 (one second) but found that the abount
  29. of CPU used by Uedit during idle time was not significantly decreased by
  30. this longer wait between idle command runs.
  31.  
  32. You also have to rename your existing idle command as virtual-4.  Or use a
  33. different key if you're already using that one (change the last runkey in the
  34. new idle command to match).  The other setup steps are to set your idleTime
  35. value permanently to 1, install a prekey with equatenum(n32, 0) in it, and
  36. replace altctl-9 (toggle auto-traffic) with the new version below.  Note that
  37. this new altctl-9 does not use userGlobalB, and you can't use a checkmarked
  38. menu item to control it.  It simply swaps virtual-t to an unused key to turn
  39. it off (virtual-3 as written), reporting whether auto-traffic mode is now on
  40. or off, putting it back on virtual-t to activate it, rather than swapping
  41. virtual-t onto idle as the old one did.  You can use any version of virtual-t.
  42.  
  43.  
  44. Combine idle save with auto-traffic: SET IDLE TIMER = 1.
  45. <idle:  while (runkey(virtual-t))  .. handle rexx commands
  46.             equatenum(n32, 0)
  47.         incnum(n32)
  48.         if (genum(n32, 80)) {  .. count of 75 means about 10-14 secs w/ 68000
  49.             equatenum(n32, 0)
  50.             runkey(virtual-4)   .. idle save
  51.         }
  52. >
  53. You must move your present idle command to virtual-4 if you want it to still
  54. work with the above dual-purpose idle command.  (Make sure you aren't using
  55. anything on virtual-4 already.)  The virtual-4 I use is basically just the
  56. standard save-on-idle command with two changes:  it does curFile last after
  57. all other buffers have been checked, and it uses userLocalA to mean "do NOT
  58. save on idle", so that save-on-idle defaults to on for new buffers.  I used
  59. to use a fancy idle save command that copied curfile to another buffer before
  60. saving it, to avoid having it lock up when I tried to type, but I stopped
  61. using that.
  62.  
  63.  
  64. Toggle auto-traffic mode while leaving idle save intact.
  65. <altctl-9:      swapkey(virtual-t, virtual-3)
  66.                 if (inuse(virtual-t))
  67.                     putmsg("Now responding to ARexx commands.")
  68.                 else putmsg("Ignoring ARexx commands.")
  69. >
  70. note that userGlobalB is not used:  you simply save your config in whichever
  71. state you like, with auto-traffic on or off, and it will remember.  NOTE that
  72. the other key you swap virtual-t with must be unused.  Or it will say "Now
  73. responding to ARexx commands" always, and might actually do something else.
  74.  
  75. =============================================================================
  76.  
  77. USE OF COMMAND LANGUAGE THROUGH REXX:  To add this ability to the Zimmerman
  78. interface, create a line in your REXXCOMM file that tells it to run virtual-
  79. f2 when it gets the command COMPILE, by adding this line:
  80.  
  81. compile         1121+0 |
  82.  
  83. ... then any rexx message that starts with the word "compile" will (if auto-
  84. traffic is on) be compiled as Uedit command language and then executed.  The
  85. reply code to rexx will be 0 if the command returned true, 1 if the command
  86. returned false, and 10 if the compile failed (in fact Uedit aborts).  In this
  87. case it leaves the failed compile sitting on the Uedit screen.  If the
  88. compile succeeds the Uedit screen will momentarily display the end of the CL
  89. command and then instantly flip back to the current buffer.  There's no way
  90. to avoid this glitch in the display with the current Uedit version.  The
  91. command is compiled using a very obscure macronum: 771.  It will return a
  92. result string consisting of the invert region of curFile, if such exists when
  93. the command completes.  It will not return a result string if the compile
  94. fails, of course.
  95.  
  96. The sequence of commands has to be sent as all one string if you want it to
  97. be executed as a single function.  And note that Uedit will receive the
  98. command all on one line even if you break it into several lines in rexx,
  99. unless you take the trouble to insert newlines in rexx like this:
  100.  
  101.    'COMPILE a line of CL blah blah blah' || '0A'x || 'another line blah blah'
  102.  
  103. This means that you can't insert Uedit comments starting with two periods
  104. except at the very end of the message, unless you put '0A'x after it.
  105.  
  106. I originally wrote this to act as a complete auto-traffic handler, replacing
  107. the standard interface, before I gave in and used the Zimmerman interface.
  108.  
  109.  
  110. Compile and run the command language in the Rexx In buffer
  111. <virtual-f2:    equatenum(n0, curfile)
  112.                 equatenum(n96, 1)               .. indicate no reply needed
  113.                 insertrgn(buf61, sfile, "<771: ", all)
  114.                 insertrgn(buf61, efile, "
  115. >", all)
  116.                 flipflag(buf61, changed)
  117.                 movecursor(buf61, sfile)
  118. .. I WISH there was some way to activate hideDisplay for this:
  119.                 editbuf(buf61)
  120.                 if (not compile) {
  121. .. one thing I like to do at this point is to restore the old search string.
  122. .. I put "getsearch(buf49)" near the top of virtual-y, and put
  123. .. "setsearch(buf49)" right here, and before each "returnfalse" in virtual-y,
  124. .. also before "label (10)" in virtual-y.
  125.  
  126. ... OPTIONAL:       runkey(virtual-1)           .. screen to front
  127.                     abort
  128.                 }
  129.                 editbuf(buf[n0])
  130.                 freebuf(buf61)
  131.                 if (runkey(771))
  132.                     equatenum(n54, 0)                           .. okay
  133.                 else equatenum(n54, 1)                          .. almost okay
  134.                 if (gtloc(curfile, einvert, sinvert))
  135.                     rexxout(curfile, invert, n54, 1, n99)
  136.                 else rexxout(" ", all, n54, 1, n99)
  137. >
  138.