home *** CD-ROM | disk | FTP | other *** search
- /* $VER: GoFetchRexx.ced 1.1 (28.10.94)
- **
- ** ARexx script to invoke FetchRefs from CygnusEd.
- */
-
- OPTIONS RESULTS
- OPTIONS FAILAT 20
- caller = ADDRESS()
-
- /* Static part of the editor's ARexx port name. That is, the name before any
- * suffixes (like '.1') are appended.
- */
- editorname = 'rexx_ced'
-
- /* Exit if we're not called from the editor */
- IF (LEFT(caller, LENGTH(editorname)) ~= editorname) then
- EXIT 10
-
- /* Get the current word from the editor. */
-
- /* Account for tabs */
- Status 8
- tabsize = result
- Menu 2 1 0
-
- /* Get some data from the editor (line contents and cursor position) */
- Status 55
- line = result
- Status 46
- position = result + 1
-
- /* Set tab size back */
- Menu 2 1 tabsize-1
-
- /* Isolate the actual word */
- function = line
- function = RIGHT(function, LENGTH(function) - position + 1)
- cutat = VERIFY(function, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_#?")
-
- IF cutat > 0 THEN
- function = LEFT(function, cutat - 1)
-
- /* Define a temporary filename to put the reference into */
- basename = 'FetchedReference'
- filename = 'T:'basename
-
- /* It doesn't matter whether we want a taglist, varargs og whatever function */
- IF RIGHT(function, 7) = "TagList" THEN
- function = LEFT(function, LENGTH(function) - 7)
- ELSE IF RIGHT(function, 4) = "Tags" THEN
- function = LEFT(function, LENGTH(function) - 4)
- ELSE IF RIGHT(function, 1) = "A" THEN
- function = LEFT(function, LENGTH(function) - 1)
-
- /* Call FetchRefs to get the reference cut out to a temporary file */
- ADDRESS 'FETCHREFS'
- FR_GET function || '(%|Tags|TagList|A)' filename CASE FILEREF
- gotoline = rc2
-
- /* Address editor again to load the file or report error */
- ADDRESS VALUE caller
-
- IF rc ~= 0 THEN DO
- /* Skip if the error was '.....!'. This occours whenever the 'select
- * from what file' window is closed, which is not really an error, so
- * I don't want it reported.
- */
- IF RIGHT(rc2, 1) = '!' THEN
- EXIT 0
-
- /* Report the error (obtained from FetchRefs) in the editor. This is
- * again editor dependant; either put up a requester, change the
- * title or do nothing - depending on your possibilities and likes.
- */
- 'okay1' RC2
-
- EXIT 0
- END
- ELSE DO
- /* Make the editor open a new window and load the autodoc into it. */
- CALL GetAView
- 'Open' filename
- 'Editable file'
- IF gotoline ~= 0 THEN
- 'jump to line' gotoline
-
- /* Delete the autodoc file */
- ADDRESS COMMAND 'C:Delete >NIL:' filename
-
- EXIT 0
- END
-
- /* GetAView - finds a previously used view or opens a new if necessary.
- * This trick requires that the same file name is used for all references.
- * This routine is specific to CygnusEd.
- */
- GetAView:
- /* Get number of views */
- 'Status 66'
- views = RESULT
-
- /* Try to find a previously used view */
- DO WHILE (views > 0)
- 'Status 21'
- viewname = RESULT
- IF (viewname = basename) THEN
- /* This is it. Break the loop */
- views = -1
- ELSE
- DO
- /* Try the next one */
- views = views - 1
- 'Next View'
- END
- END
- /* Open a new view if we have to */
- IF (views = 0) THEN
- 'Open New'
- RETURN
-