home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / misc / FetchRefs1.3.lha / FetchRefs1.3 / Scripts / GoFetchRefs.ttx < prev   
Encoding:
Text File  |  1996-02-24  |  2.0 KB  |  86 lines

  1. /*   $VER: GoFetchRexx.ttx 1.2 (24.2.96)
  2. **
  3. **   ARexx script to invoke FetchRefs from TurboText.
  4. **   
  5. */
  6.  
  7. OPTIONS RESULTS
  8. caller = ADDRESS()
  9.  
  10. /* Static part of the ARexx port name of the editor. That is, the name before 
  11.  * any suffixes (like '.1') are appended.
  12.  */
  13. editorname = 'TURBOTEXT'
  14.  
  15. /* Exit if we're not called from the editor */
  16. IF (LEFT(caller, LENGTH(editorname)) ~= editorname) then
  17.     EXIT 10
  18.  
  19. /* Get the current word from the editor, reading char by char */
  20. 'SetDisplayLock ON'
  21.  
  22. position = 0
  23. function = ''
  24. 'GetChar'
  25. char = result
  26. DO WHILE VERIFY(char, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_") = 0
  27.     function = function || char
  28.     'MoveRight'
  29.     position = position + 1
  30.     'GetChar'
  31.     char = result
  32. END
  33. DO WHILE position > 0
  34.     'MoveLeft'
  35.     position = position - 1
  36. END
  37.  
  38. 'SetDisplayLock OFF'
  39.  
  40. /* It doesn't matter whether we want a taglist, varargs og whatever function */
  41. IF RIGHT(function, 7) = "TagList" THEN
  42.     function = LEFT(function, LENGTH(function) - 7)
  43. ELSE IF RIGHT(function, 4) = "Tags" THEN
  44.     function = LEFT(function, LENGTH(function) - 4)
  45. ELSE IF RIGHT(function, 1) = "A" THEN
  46.     function = LEFT(function, LENGTH(function) - 1)
  47.  
  48. /* Define a temporary filename to put the reference into */
  49. filename = 'T:FR_' || function
  50.  
  51. /* Now actually get the reference */
  52. ADDRESS 'FETCHREFS'
  53. FR_GET function || '(%|Tags|TagList|A)' filename FILEREF
  54. gotoline = rc2
  55.  
  56. /* Address editor again to load the file or report error */
  57. ADDRESS VALUE caller
  58.  
  59. IF rc ~= 0 THEN DO
  60.     /* Some kind of error happend. Report it. This may be a simple
  61.      * "Aborted" or "No reference" message.
  62.      */
  63.     'SetStatusBar Temporary' rc2
  64.  
  65.     EXIT 0
  66. END
  67. ELSE DO
  68.     /* Make the editor open a new window and load the autodoc into it. */
  69.     'OpenDoc NAME' filename
  70.     docPort = result
  71.     ADDRESS VALUE docPort
  72.     'SetDisplayLock ON'
  73.  
  74.     /* Jump to the suggested line */
  75.     IF gotoline ~= 0 THEN
  76.     'Move FOLDS' gotoline
  77.  
  78.     'SetDisplayLock OFF'
  79.  
  80.     /* Delete the temporary file */
  81.     ADDRESS COMMAND 'C:Delete >NIL:' filename
  82.  
  83.     EXIT 0
  84. END
  85.  
  86.