home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff297.lzh / DevKit / Rexx / LookUp.ced < prev    next >
Text File  |  1989-12-29  |  3KB  |  149 lines

  1. /************************************************************************
  2.  *
  3.  * LookUp.ced                        Copyright (c) 1989, Peter Cherna
  4.  *
  5.  * ARexx program for CygnusEd Professional that looks up the word under
  6.  * the cursor in the autodocs.
  7.  *
  8.  * Version 1.30:  August 20, 1989    Release 1.2:  August 29, 1989
  9.  *
  10.  ************************************************************************/
  11.  
  12. options results
  13.  
  14. address 'rexx_ced'
  15.  
  16. tabchar = '09'X
  17.  
  18. /*    Get contents of current line: */
  19. status 55
  20. line = result
  21.  
  22. /*    Get tab size: */
  23. status 8
  24. tabadjust = result - 1
  25.  
  26. /*    Get cursor x position (relative to beginning of line = 1): */
  27. status 46
  28. cur = result + 1
  29.  
  30. i = index(line,tabchar)
  31. DO while i > 0 & i <= cur - tabadjust
  32.     cur = cur - tabadjust
  33.     i = index(line,tabchar,i+1)
  34. END
  35.  
  36. /*    If the current character is non-alphabetic, then start one character
  37.     over to the left.  This allows the cursor to be immediately after
  38.     the key word (say on a space or bracket.) */
  39.  
  40. char = substr(line,cur,1)
  41. if (~(datatype(char,'A') | char = '_') & cur > 1) then
  42.     cur = cur - 1
  43.  
  44. /*    Find leftmost and rightmost alphabetic character adjacent to current: */
  45.  
  46. right = cur - 1
  47. left = cur + 1
  48. char = 'A'
  49. DO while (datatype(char,'A') | char = '_') & (left > 0)
  50.      left = left - 1
  51.     if left > 0 then
  52.         char = substr(line,left,1)
  53. END
  54. char = 'A'
  55. DO while (datatype(char,'A') | (char = '_'))
  56.     right = right + 1
  57.     char = substr(line,right,1)
  58. END
  59.  
  60. if right-left <= 1 then
  61. DO
  62.     getstring
  63.     target = result
  64.     if (target = 'RESULT') then
  65.         exit
  66. END
  67. else
  68. DO
  69.     target = substr(line,left+1,right-left-1)
  70. END
  71.  
  72. DO
  73.     address command 'WBTF'
  74.     say 'Searching for function' target '...'
  75.  
  76.     filename = 'RAM:' || target || '.autodoc'
  77.  
  78.     address command 'GetAutoDoc >' || filename target
  79.     if open('autodocfile',filename) = 0 then
  80.     DO
  81.         cedtofront
  82.         okay1 'Could not find "GetAutoDoc".'
  83.         exit
  84.     END
  85.     else
  86.     DO
  87.         line = readln('autodocfile')
  88.         call close 'autodocfile'
  89.  
  90.         if left(line,1) = '-' then
  91.         DO
  92.             address command 'delete' filename
  93.             cedtofront
  94.             okay1 substr(line,3)
  95.             exit
  96.         END
  97.         else
  98.         DO
  99.             /*  If we have a help file displayed, use its window,
  100.                 else open a new one: */
  101.  
  102.             helpfile = getclip('HelpWindow')
  103.             /*    Get name of current file */
  104.             status 21
  105.             if helpfile ~= result then
  106.             DO
  107.                 /* Find out how many views are displayed */
  108.                 status 66
  109.  
  110.                 /* Try to find the view containing the help file */
  111.                 DO numwins=result-1 to 1 by -1 until result = helpfile
  112.                     next view
  113.                     /*    Get name of current file */
  114.                     status 21
  115.                 END
  116.             END
  117.  
  118.             /* If we can't find the file, then ask to open it */
  119.             if result ~= helpfile then
  120.             DO
  121.                 next view        /* bring back to original view */
  122.                 open new
  123.             END
  124.             else
  125.             DO
  126.                 /*    Only replace this file if there have been no
  127.                     changes.  Get number of changes: */
  128.                 status 18
  129.                 if result ~= 0 then
  130.                 DO
  131.                     next view
  132.                     open new
  133.                 END
  134.             END
  135.  
  136.             cedtofront
  137.             /*    Set tab size to eight: */
  138.             menu 2 1 7
  139.             open filename
  140.  
  141.             /*    Save file name of the Help Window */
  142.             status 21
  143.             call setclip 'HelpWindow',result
  144.         END
  145.         address command 'delete' filename
  146.     END
  147. END
  148. exit
  149.