home *** CD-ROM | disk | FTP | other *** search
- ======= AREXX CMDS ======
- Major modifications to this file by Kerry Zimmerman [71470,1340] 4/14/89
- o Changed output buffer to 62, input buffer to 61 to avoid conflict with
- Eric Kennedy's VI extensions.
- o altctl-9 now displays current autotraffic status
- o altctl-0 now asks for a command name and a list of macronums.
- It adds these to the end of file U:REXXCOMM. This file is a database
- of macros understood by the new rexx autotraffic handler.
-
- Edit Rexx output buffer 62
- <altCtl-1:
- equateLoc(buf62,sPage,sFile)
- editBuf(buf62) >
-
- Edit Rexx input buffer 61
- <altCtl-2:
- equateLoc(buf61,sPage,sFile)
- editBuf(buf61) >
-
- Send output buffer 62 to Rexx
- <altCtl-3:
- equateNum(n98,0) .. 0 flag means send msg, not reply
- rexxOut(buf62,all,0,n98,n99) .. 0 ActionResult means default to RXCOMM
- runKey(virtual-s) >
-
- Fetch Rexx input into buffer 61
- <altCtl-4:
- if (rexxIn(buf61,sFile,n97,n98,n99)) {
- ..if (eqNum(n98,0)) { .. if Msg
- equateLoc(buf61,sPage,sFile)
- editBuf(buf61)
- ..}
- }
- runKey(virtual-r) >
-
- Send hilite region to Rexx.
- <altCtl-5:
- equateNum(n98,0) .. 0 means msg, not reply
- rexxOut(curFile,hilite,0,n98,n99) .. 0 means default to Action = RXCOMM
- runKey(virtual-s) >
-
- Fetch Rexx input at cursor
- <altCtl-6:
- rexxIn(curFile,atCursor,n97,n98,n99)
- runKey(virtual-r) >
-
- Send an OK reply to Rexx (NOTE: Amiga-ESC abort sends Failed reply.)
- <altCtl-7:
- equateNum(n98,1) .. 1 means reply, not msg
- rexxOut(" ",all,0,n98,n99) .. 0 is OKAY result
- runKey(virtual-s) >
-
- Send an OK reply to Rexx along with text in hilite region
- <altCtl-8:
- equateNum(n98,1)
- rexxOut(curFile,hilite,0,n98,n99) ..text NOT sent, if not RXFB_RESULT msg
- runKey(virtual-s) >
-
- Toggle flag to handle Rexx traffic automatically during idle periods.
- <altCtl-9:
- .. set idletime back to old value
- if (getFlag(curFile,userGlobalB)) {
- equateNum(idleTime,n36)
- putMsg("AutoTraffic is OFF")
- }
- else { .. idleTime not 0, toggle to auto-traffic handling
- equateNum(n36,idleTime) .. store idleTime in n36
- equateNum(idleTime,0) .. set idleTime to 0
- putMsg("AutoTraffic is ON")
- }
- flipFlag(curFile,userGlobalB) .. toggle flag
- swapKey(idle,virtual-t) .. swap in/out the auto-traffic idle cmd
- >
-
-
- Make an x.rexx program with commands to send to Uedit.
- <altCtl-0:
- freebuf(buf35)
- if (!loadfile("REXXCOMM")) loadfile("S:REXXCOMM")
- movecursor(curFile,eFile)
- putmsg("Enter new command's name")
- freebuf(buf50)
- inputString(buf50)
- insertRgn(curFile,atCursor,buf50,all)
- insertRgn(curFile,atCursor," |
- ",all)
- movecursor(curFile,sChar)
- movecursor(curFile,sChar)
- updateDisplay
- while (nothing) {
- putMsg("Give desired inputs. Amiga-ESC when done. F2 to save.")
- getKeyVal(macroNum,inputChar)
- toWord(curFile,macroNum)
- insertChar(curFile,"+")
- toWord(curFile,inputChar)
- insertChar(curFile," ")
- updateDisplay
- fileSize(curFile,n54) .. force pack, avoid mem-abort
- }
- >
-
- <virtual-t:
- if (rexxIn(buf61,eFile,n97,n98,n99)) { .. if fetched something
- ..runKey(virtual-r) .. show flags - slower if use this line
- if (eqNum(n98,0)) { .. if recvd a Msg, not a Reply
-
- equateNum(n96,0)
- push(n99,searchCaps) .. (RS mod)
- equateNum(searchCaps,0) .. turn off case sensitivity (RS mod)
- runkey(virtual-y)
- pop(n99,searchCaps) .. restore orig case sensitivity (RS mod)
- freeBuf(buf61)
- if(not eqNum(n96,0)) return .. comand already sent a reply
- if(eqLoc(curFile,sInvert,eInvert)) goto label(50)
- rexxOut(curFile,Invert,0,1,n99) .. search uses this as an example
- return
-
- label(50) rexxOut(" ",all,0,1,n99)
- }
- }
- >
-
- handle named macro messages
- <virtual-y:
- .. if buf35 doesn't contain the named commands yet
- .. read it in
- moveCursor(buf35,sfile)
- freeBuf(buf50)
- insertRgn(buf50,atCursor,"REXXCOMM",all)
- setSearch(buf50)
- if(not search(buf35,sHilite,eHilite,1)) {
- freeBuf(buf35)
- if(!insertFile(buf35,sfile,"REXXCOMM")
- & !insertFile(buf35,sfile,"S:REXXCOMM")) {
- putmsg("file REXXCOMM not found")
- returnFalse
- }
- }
-
- .. extract 1st word of buf61 which is the command
- moveCursor(buf61,sfile)
- equateLoc(buf61,sHilite,atCursor)
- moveCursor(buf61,eWord)
- equateLoc(buf61,eHilite,atCursor)
- freebuf(buf50)
- insertRgn(buf50,sFile,buf61,Hilite) ..save command
-
- clearRgn(buf61,Hilite) ..erase command leaving any args
- while(is(buf61,whiteSpace))
- clearChar(buf61)
- setSearch(buf50)
-
- .. search for this command in list of commands in buf35
- moveCursor(buf35,sfile)
- moveCursor(buf35,eLine) .. start search after 1st line
- if(not search(buf35,sHilite,eHilite,1)) {
- freeBuf(buf54)
- insertRgn(buf54,efile,"REXX command NOT found: ",all)
- insertRgn(buf54,efile,buf50,all)
- returnFalse
- }
-
- .. move to the first macronum
- moveCursor(buf35,eHilite)
-
- .. process each macronum+inputchar pair until "|" found
-
- label(10)
- while(is(buf35,whitespace))
- moveCursor(buf35,echar)
- .. return if end of commands
- if(is(buf35,"|") | is(buf35,eFile)) returnTrue
-
- .. convert xx+yy to macronum-xx, inputchar-yy
- equateNum(macroNum,0)
- equateNum(inputChar,0)
- if(is(buf35,digit)) {
- toNumber(macroNum,buf35)
- while(is(buf35,digit))
- moveCursor(buf35,echar)
- if(is(buf35,"+")){
- moveCursor(buf35,echar)
- if(is(buf35,digit)){
- toNumber(inputChar,buf35)
- while(is(buf35,digit))
- moveCursor(buf35,echar)
- }
- }
- }
- .. run valid macroNum, or type valid inputChar
- if(inUse(macroNum)) runKey(macroNum)
- else if(gtNum(inputChar,0)) TypeChar(inputChar)
- else return
- goto label(10) >
-
-
- Show numbers for a received Arexx msg or reply
- <virtual-r:
- if (not eqNum(n99,0)) runKey(virtual-m) .. rexxIn() failed
- else { .. rexxIn() succeeded
- if (eqNum(n98,0)) { .. MSG: show action & modifiers
- and(n96,n97,0X0F000000) .. get ACTION code
- and(n95,n97,0X000F0000) .. get MODIFIER
- if(gtNum(n95,0)) div(n95,n95,0x10000)
- freeBuf(buf54)
- insertRgn(buf54,atCursor,"Msg fetched: Action = ",all)
- toWord(buf54,n96)
- insertRgn(buf54,atCursor," Modifier = ",all)
- toWord(buf54,n95)
- ..insertRgn(buf54,atCursor," -- press return",all)
- putMsg(buf54)
- } else { .. REPLY:
- if (eqNum(n97,0)) putMsg("Reply fetched. Result OKAY")
- else {
- freeBuf(buf54)
- insertRgn(buf54,atCursor,
- "Reply received: Result = ERROR ",all)
- toWord(buf54,n97)
- ..insertRgn(buf54,atCursor," -- press return",all)
- putMsg(buf54)
- }
- }
- }
- ..getkey(n50)
- >
-
- Show numbers for a sent ARexx msg or reply
- <virtual-s:
- if (not eqNum(n99,0)) runKey(virtual-m) .. rexxOut() failed
- else {
- if (eqNum(n98,0)) putMsg("Msg sent")
- else putMsg("Reply sent")
- }
- >
-
- Show returncode error msgs
- <virtual-m:
- switch(n99) {
- case(-1) { putMsg("ARexx not up") }
- case(-2) { putMsg("No memory or no text") }
- case(-3) { putMsg("Msg/reply > 65535 bytes") }
- case(-4) { putMsg("Nothing to fetch or reply to") }
- case(-5) { putMsg("Fetch reply before sending this msg/reply") }
- }
- returnFalse .. so virtual-r/-s above will return False
- >
-
- ====================================================================
- Some useful functions for the arexx macros
-
- The 'ask' macro. Usage: ask 'Do you want to continue?'
- ask a question and return true or false
- <virtual-i:
- equateNum(n96,1)
- if(askYesNo(buf61))
- rexxOut("YES",all,0,1,n99)
- else
- rexxOut("NO",all,0,1,n99)
- >
-
- the 'text' macro. Usage: text 'this will be inserted'
- insert text at cursor
- <virtual-h: insertRgn(curFile,atCursor,buf61,all)
- updatedisplay>
-
- the 'loadfile' macro. Usage: loadfile 'sys:myfile'
- edit given file
- <virtual-j: loadfile(buf61)>
-
- the 'gotoline' macro Usage: gotoline 100
- goto line
- <virtual-n: toNumber(n50,buf61)
- lineToLoc(curFile,atCursor,n50) >
-
- the 'searchfor' macro Usage: searchfor pattern
- search for a given string
- <virtual-o: push(buf99,buf61)
- pop(buf99,buf49)
- setsearch(buf49)
- runkey(normal-f9) >
-
- The 'message' macro Usage: message 'my message'
- issue a message
- <virtual-p: putmsg(buf61) >
-
-