home *** CD-ROM | disk | FTP | other *** search
- /*
- * Reference Macro for TxEd. Supposed to work like the
- * reference utility in dme. REQUIRES THE FULL AREXX SYSTEM
- * TO WORK. (rename file to reference.txed)
- */
-
- /* I prefer to check for errors manually. (jac) */
- /* SIGNAL ON ERROR */ /* catch any errors */
- /* OPTIONS FAILAT 60 */ /* but don't die and go away */
-
- OPTIONS RESULTS
-
- 'WORD' /* This little move (he he) puts the cursor at the */
- MWORD /* beginning of the word, even if it's not originally */
- /* jac */
-
- MARK 1 /* get the current word from TxEd */
- 'WORD'
- 'COPY +X'
- 'STATUS M+X'
-
- /* In case the cursor was positioned on some white space: */
-
- find = strip(result,,' ') /* strip character is a blank */
- find = strip(find,,'09'x) /* strip character is a tab */
-
- /* put a nice message on the txed window */
-
- line = "Attempting to reference" find
- msg line
-
- /* Extract the 'stuff' if it exists. If an error is encountered */
- /* here, call ERROR: */
-
- address COMMAND 'getrefs' find
-
- if rc > 0 then
- call ERROR
- else nop /* A reference exists */
-
- /* Check to see if the reference window has been opened, */
- /* and if so, is it still open. */
-
- alreadyopen = 0
- newtxed = getclip("Reference")
- if length(newtxed) > 0 then do /* The reference window has been */
- /* previously opened. */
- portlist = showlist('P') /* Check to see if it's still there.*/
- testfile = index(portlist,newtxed)
- if testfile = 0 then /* Nope -- open it. */
- newtxed = OpenRefTxEd()
- else
- alreadyopen = 1
- end
-
- else /* No window open -- open it. */
- newtxed = OpenRefTxEd()
-
- if newtxed = "1" then do /* Couldn't open new window. */
- line = "Can't open new TxEd window"
- msg line
- exit
- end
-
- /* Tell new txed to move to top of screen and display extracted text */
- /* this particular set of commands will display the function call */
- /* template if you are referencing the autodocs. change to taste */
-
- address value newtxed
-
- 'load ram:extract.txt'
- top
- down 4
-
- /*
- Now tell the original txed to get out of the way and
- activate itself This is a kludge since you might have resized
- the main TxEd window. It would be nice if there were a call
- that would return the current window size.
- */
-
- if ~alreadyopen then do
- address
- 'window 0 2 640 109'
- end
-
- /* be nice and tidy by deleteing the temporary file */
-
- address COMMAND 'delete ram:extract.txt'
-
- exit
-
-
- /*==========================================================================*/
- /* This function opens a new TxEd window, wait's for it to */
- /* get set up, and then returns its address. */
- /*==========================================================================*/
-
- OpenRefTxEd: procedure
-
- trace results
-
- line = setclip("Reference","1")
- address COMMAND "e STARTUP refstartup"
-
- newtxed = "1"
- do for 20 until newtxed ~= "1"
- address COMMAND 'c:wait'
- newtxed = getclip("Reference") /* get address of new txed */
- /* if newtxed ~= "1" then leave */
- end
-
- return newtxed
-
-
- /*==========================================================================*/
- /* Error handling. The error code will be in the variable rc so we can */
- /* construct a specific error message to send back to the original txed. */
- /*==========================================================================*/
-
- ERROR:
-
- select
- when rc = 1 then line = "Can't fine GetRefs!"
- when rc = 50 then line = "Bad command line to GetRefs command"
- when rc = 51 then line = "Can't open reference file TxEd.refs"
- when rc = 52 then line = "Reference string" find "was not found"
- when rc = 53 then line = "Bad line format in TxEd.refs - couldn't decode"
- when rc = 54 then line = "Can't open reference source file"
- when rc = 55 then line = "Can't find referenced text"
- when rc = 56 then line = "Can't open ram:extract.txt - bad news"
- otherwise line = "Unrecognized error - something is very wrong"
- end
- msg line
- exit /* We don't exit with an error code since that erases our nice message. */
-