home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d7xx / d768 / uedit.lha / Uedit / Config!R < prev    next >
Text File  |  1992-11-22  |  10KB  |  340 lines

  1. -----------------------------------------------------------------------------
  2. |                              Config!R                                        |
  3. |         Placed in the public domain July 92 Rick Stiles.                    |
  4. -----------------------------------------------------------------------------
  5.  
  6. *************************************
  7. N-variables used:
  8. n0-n1scratch numbers
  9. n26 used by rexx
  10. n27 action/result
  11. n28 rexx flag
  12. n29 rexx return code
  13.  
  14. Buffers used:
  15. buf50 & buf51    scratch buffers
  16.  
  17. buf36    REXXCOMM buf
  18. buf49    search buf
  19. buf61    rexx in buf
  20. buf62    rexx out buf
  21.  
  22. *************************************
  23.  
  24. <defines:
  25. define(N_0,n0)
  26. define(N_1,n1)
  27. define(RX_VAR,n26)
  28. define(ACT_RESULT,n27)
  29. define(FLAG_BITS,n28)
  30. define(RTN_CODE,n29)
  31. define(NSTACK_99,n99)        .. note n99 not really used
  32. define(B_0,buf50)
  33. define(B_1,buf51)
  34. define(BSTACK_99,buf99)     .. note buf99 not really used
  35. define(REXX_COMM_BUF,buf36)
  36. define(SEARCH_STR,buf49)
  37. define(REXX_IN_BUF,buf61)
  38. define(REXX_OUT_BUF,buf62)
  39. >
  40.  
  41.  
  42. ======= AREXX CMDS ======
  43. Major modifications to this file by Kerry Zimmerman [71470,1340] 4/14/89
  44. o  Changed output buffer to 62, input buffer to 61 to avoid conflict with
  45.    Eric Kennedy's VI extensions.
  46. o  altctl-0 now asks for a command name and a list of macronums.
  47.    It adds these to the end of file U:REXXCOMM.  This file is a database
  48.    of macros understood by the new rexx autotraffic handler.
  49.  
  50. Edit Rexx output buffer 62
  51. <altCtl-1:
  52.     equateLoc(REXX_OUT_BUF,sPage,sFile)
  53.     editBuf(REXX_OUT_BUF) >
  54.  
  55. Edit Rexx input buffer 61
  56. <altCtl-2:
  57.     equateLoc(REXX_IN_BUF,sPage,sFile)
  58.     editBuf(REXX_IN_BUF) >
  59.  
  60. Send output buffer 62 to Rexx
  61. <altCtl-3:
  62.     equateNum(FLAG_BITS,0)                     .. 0 flag means send msg, not reply
  63.     rexxOut(REXX_OUT_BUF,all,0,FLAG_BITS,RTN_CODE)   .. 0 ActionResult means default to RXCOMM
  64.     runKey(virtual-s) >
  65.  
  66. Fetch Rexx input into buffer 61
  67. <altCtl-4:
  68.     if (rexxIn(REXX_IN_BUF,sFile,ACT_RESULT,FLAG_BITS,RTN_CODE)) {
  69.         ..if (eqNum(FLAG_BITS,0)) {       .. if Msg
  70.             equateLoc(REXX_IN_BUF,sPage,sFile)
  71.             editBuf(REXX_IN_BUF)
  72.         ..}
  73.      }
  74.      runKey(virtual-r) >
  75.  
  76. Send hilite region to Rexx.
  77. <altCtl-5:
  78.     equateNum(FLAG_BITS,0)                               .. 0 means msg, not reply
  79.     rexxOut(curFile,hilite,0,FLAG_BITS,RTN_CODE)  .. 0 means default to Action = RXCOMM
  80.     runKey(virtual-s) >
  81.  
  82. Fetch Rexx input at cursor
  83. <altCtl-6:
  84.     rexxIn(curFile,atCursor,ACT_RESULT,FLAG_BITS,RTN_CODE)
  85.     runKey(virtual-r) >
  86.  
  87. Send an OK reply to Rexx  (NOTE: Amiga-ESC abort sends Failed reply.)
  88. <altCtl-7:
  89.     equateNum(FLAG_BITS,1)                               .. 1 means reply, not msg
  90.     rexxOut(" ",all,0,FLAG_BITS,RTN_CODE)                            .. 0 is OKAY result
  91.     runKey(virtual-s) >
  92.  
  93. Send an OK reply to Rexx along with text in hilite region
  94. <altCtl-8:
  95.     equateNum(FLAG_BITS,1)
  96.     rexxOut(curFile,hilite,0,FLAG_BITS,RTN_CODE) ..text NOT sent, if not RXFB_RESULT msg
  97.     runKey(virtual-s) >
  98.  
  99. Add new command-words to REXXCOMM
  100. <altCtl-0:
  101.     loadFile("REXXCOMM")
  102.     if (isEmpty(curFile)) {
  103.         if (!isEmpty(REXX_COMM_BUF)) {
  104.             swapBuf(curFile,REXX_COMM_BUF)
  105.             freebuf(REXX_COMM_BUF)
  106.             setFileName(curFile,"S:REXXCOMM")
  107.         } else {
  108.             freeBuf(curFile)
  109.             loadfile("S:REXXCOMM")
  110.             if (isEmpty(curFile)) {
  111.                 freeBuf(curFile)
  112.                 putMsg("Can't find REXXCOMM")
  113.                 returnFalse
  114.             }
  115.         }
  116.     } else freeBuf(REXX_COMM_BUF)
  117.     downFlag(curFile,readonly)
  118.     while (nothing) {
  119. label(1)
  120.         movecursor(curFile,eFile)
  121.         updateDisplay
  122.         putmsg("Enter new command name (ESC when done):")
  123.         freebuf(B_0)
  124.         if (!inputString(B_0)) {
  125. label(0)
  126.             if (getFlag(curFile,CHANGED) & !isEmpty(curFile)) {
  127.                 if (askYesNo("Save modified REXXCOMM")) saveFile(curFile)
  128.             }
  129.             return
  130.         }
  131.         moveCursor(B_0,sfile)
  132.         copyChar(B_0,N_0)
  133.         if (geNum(" ",N_0)) goto label(0)
  134.         insertRgn(curFile,atCursor,B_0,all)
  135.         insertRgn(curFile,atCursor,"        |
  136. ",all)
  137.         movecursor(curFile,sChar)
  138.         movecursor(curFile,sChar)
  139.         updateDisplay
  140.         while (nothing) {
  141.             putMsg("Give desired inputs.  ESC when done.")
  142.             getKeyVal(macroNum,inputChar)
  143.             if (eqNum(macroNum,normal-esc)) goto label(1)
  144.             toWord(curFile,macroNum)
  145.             insertChar(curFile,"+")
  146.             toWord(curFile,inputChar)
  147.             insertChar(curFile," ")
  148.             updateDisplay
  149.             fileSize(curFile,N_0) .. force pack, avoid mem-abort
  150.         }
  151.     }
  152. >
  153.  
  154. <virtual-t:     .. swap this into rexxKey cmd when autoTraffic is used.
  155.     if (rexxIn(REXX_IN_BUF,eFile,ACT_RESULT,FLAG_BITS,RTN_CODE)) {           .. if fetched something
  156.         ..runKey(virtual-r)         .. show flags - slower if use this line
  157.         if (eqNum(FLAG_BITS,0)) {                    .. if recvd a Msg, not a Reply
  158.  
  159.             equateNum(RX_VAR,0)
  160.             push(NSTACK_99,searchCaps)     .. (RS mod)
  161.             equateNum(searchCaps,0) .. turn off case sensitivity (RS mod)
  162.             runkey(virtual-y)
  163.             pop(RTN_CODE,searchCaps)      .. restore orig case sensitivity (RS mod)
  164.             freeBuf(REXX_IN_BUF)
  165.             if(not eqNum(RX_VAR,0)) return .. comand already sent a reply
  166.             if(eqLoc(curFile,sInvert,eInvert)) goto label(50)
  167.             rexxOut(curFile,Invert,0,1,RTN_CODE) .. search uses this as an example
  168.             return
  169.  
  170. label(50)    rexxOut(" ",all,0,1,RTN_CODE)
  171.         }
  172.     }
  173. >
  174.  
  175. handle named macro messages
  176. <virtual-y:
  177. .. if REXX_COMM_BUF doesn't contain the named commands yet
  178. .. read it in
  179.     moveCursor(REXX_COMM_BUF,sfile)
  180.     freeBuf(B_0)
  181.     insertRgn(B_0,atCursor,"REXXCOMM",all)
  182.             setSearch(B_0)
  183.             if(not search(REXX_COMM_BUF,sHilite,eHilite,1)) {
  184.         freeBuf(REXX_COMM_BUF)
  185.         if(!insertFile(REXX_COMM_BUF,sfile,"REXXCOMM")
  186.             & !insertFile(REXX_COMM_BUF,sfile,"S:REXXCOMM")) {
  187.             putmsg("file REXXCOMM not found")
  188.             returnFalse
  189.         }
  190.     }
  191.  
  192. .. extract 1st word of REXX_IN_BUF which is the command
  193.     moveCursor(REXX_IN_BUF,sfile)
  194.     equateLoc(REXX_IN_BUF,sHilite,atCursor)
  195.     moveCursor(REXX_IN_BUF,eWord)
  196.     equateLoc(REXX_IN_BUF,eHilite,atCursor)
  197.     freebuf(B_0)
  198.     insertRgn(B_0,sFile,REXX_IN_BUF,Hilite) ..save command
  199.  
  200.     clearRgn(REXX_IN_BUF,Hilite) ..erase command leaving any args
  201.     while(is(REXX_IN_BUF,whiteSpace))
  202.         clearChar(REXX_IN_BUF)
  203.     setSearch(B_0)
  204.  
  205. .. search for this command in list of commands in REXX_COMM_BUF
  206.     moveCursor(REXX_COMM_BUF,sfile)
  207.     moveCursor(REXX_COMM_BUF,eLine) .. start search after 1st line
  208.     if(not search(REXX_COMM_BUF,sHilite,eHilite,1)) {
  209.         freeBuf(B_1)
  210.         insertRgn(B_1,efile,"REXX command NOT found: ",all)
  211.         insertRgn(B_1,efile,B_0,all)
  212.         returnFalse
  213.     }
  214.  
  215. .. move to the first macronum
  216.     moveCursor(REXX_COMM_BUF,eHilite)
  217.  
  218. .. process each macronum+inputchar pair until "|" found
  219.  
  220. label(10)
  221.     while(is(REXX_COMM_BUF,whitespace))
  222.         moveCursor(REXX_COMM_BUF,echar)
  223. .. return if end of commands
  224.     if(is(REXX_COMM_BUF,"|") | is(REXX_COMM_BUF,eFile)) returnTrue
  225.  
  226. .. convert xx+yy to macronum-xx, inputchar-yy
  227.     equateNum(macroNum,0)
  228.     equateNum(inputChar,0)
  229.     if(is(REXX_COMM_BUF,digit)) {
  230.         toNumber(macroNum,REXX_COMM_BUF)
  231.         while(is(REXX_COMM_BUF,digit))
  232.             moveCursor(REXX_COMM_BUF,echar)
  233.         if(is(REXX_COMM_BUF,"+")){
  234.             moveCursor(REXX_COMM_BUF,echar)
  235.             if(is(REXX_COMM_BUF,digit)){
  236.                 toNumber(inputChar,REXX_COMM_BUF)
  237.                 while(is(REXX_COMM_BUF,digit))
  238.                     moveCursor(REXX_COMM_BUF,echar)
  239.             }
  240.         }
  241.     }
  242.     .. run valid macroNum, or type valid inputChar
  243.     if(inUse(macroNum)) runKey(macroNum)
  244.     else if(gtNum(inputChar,0)) TypeChar(inputChar)
  245.     else return
  246.     goto label(10) >
  247.  
  248.  
  249. Show numbers for a received Arexx msg or reply
  250. <virtual-r:
  251.     if (not eqNum(RTN_CODE,0)) runKey(virtual-m)           .. rexxIn() failed
  252.     else {                                         .. rexxIn() succeeded
  253.         if (eqNum(FLAG_BITS,0)) {               .. MSG: show action & modifiers
  254.             and(RX_VAR,ACT_RESULT,0X0F000000)                 .. get ACTION code
  255.             and(N_1,ACT_RESULT,0X000F0000)                .. get MODIFIER
  256.             if(gtNum(N_1,0)) div(N_1,N_1,0x10000)
  257.             freeBuf(B_1)
  258.             insertRgn(B_1,atCursor,"Msg fetched:  Action = ",all)
  259.             toWord(B_1,RX_VAR)
  260.             insertRgn(B_1,atCursor,"  Modifier = ",all)
  261.             toWord(B_1,N_1)
  262.             ..insertRgn(B_1,atCursor,"  -- press return",all)
  263.             putMsg(B_1)
  264.         } else {                                              .. REPLY:
  265.             if (eqNum(ACT_RESULT,0)) putMsg("Reply fetched.  Result OKAY")
  266.             else {
  267.                 freeBuf(B_1)
  268.                 insertRgn(B_1,atCursor,
  269.                     "Reply received:  Result = ERROR ",all)
  270.                 toWord(B_1,ACT_RESULT)
  271.                 ..insertRgn(B_1,atCursor,"  -- press return",all)
  272.                 putMsg(B_1)
  273.             }
  274.         }
  275.     }
  276. ..getkey(N_0)
  277. >
  278.  
  279. Show numbers for a sent ARexx msg or reply
  280. <virtual-s:
  281.         if (not eqNum(RTN_CODE,0)) runKey(virtual-m)          .. rexxOut() failed
  282.         else {
  283.             if (eqNum(FLAG_BITS,0)) putMsg("Msg sent")
  284.             else              putMsg("Reply sent")
  285.         }
  286. >
  287.  
  288. Show returncode error msgs
  289. <virtual-m:
  290.     switch(RTN_CODE) {
  291.     case(-1) { putMsg("ARexx not up") }
  292.     case(-2) { putMsg("No memory or no text") }
  293.     case(-3) { putMsg("Msg/reply > 65535 bytes") }
  294.     case(-4) { putMsg("Nothing to fetch or reply to") }
  295.     case(-5) { putMsg("Fetch reply before sending this msg/reply") }
  296.     }
  297.     returnFalse                   .. so virtual-r/-s above will return False
  298. >
  299.  
  300. ====================================================================
  301. Some useful functions for the arexx macros
  302.  
  303. The 'ask' macro.  Usage:  ask 'Do you want to continue?'
  304. ask a question and return true or false
  305. <virtual-i:
  306.     equateNum(RX_VAR,1)
  307.     if(askYesNo(REXX_IN_BUF))
  308.         rexxOut("YES",all,0,1,RTN_CODE)
  309.     else
  310.         rexxOut("NO",all,0,1,RTN_CODE)
  311. >
  312.  
  313. the 'text' macro.  Usage:  text 'this will be inserted'
  314. insert text at cursor
  315. <virtual-h: insertRgn(curFile,atCursor,REXX_IN_BUF,all)
  316.             updatedisplay>
  317.  
  318. the 'loadfile' macro.  Usage: loadfile 'sys:myfile'
  319. edit given file
  320. <virtual-j:    loadfile(REXX_IN_BUF)>
  321.  
  322. the 'gotoline' macro  Usage: gotoline 100
  323. goto line
  324. <virtual-n:    toNumber(N_0,REXX_IN_BUF) lineToLoc(curFile,atCursor,N_0) >
  325.  
  326. the 'searchfor' macro  Usage: searchfor pattern
  327. search for a given string
  328. <virtual-o:
  329.     push(BSTACK_99,REXX_IN_BUF)
  330.     pop(BSTACK_99,SEARCH_STR)
  331.     setsearch(SEARCH_STR)
  332.     runkey(normal-f9) >
  333.  
  334. The 'message' macro  Usage: message 'my message'
  335. issue a message
  336. <virtual-p:    putmsg(REXX_IN_BUF) >
  337.  
  338.  
  339. <defines: >
  340.