home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- *
- * LookUp.ced Copyright (c) 1989, Peter Cherna
- *
- * ARexx program for CygnusEd Professional that looks up the word under
- * the cursor in the autodocs.
- *
- * Version 1.30: August 20, 1989 Release 1.2: August 29, 1989
- *
- ************************************************************************/
-
- options results
-
- address 'rexx_ced'
-
- tabchar = '09'X
-
- /* Get contents of current line: */
- status 55
- line = result
-
- /* Get tab size: */
- status 8
- tabadjust = result - 1
-
- /* Get cursor x position (relative to beginning of line = 1): */
- status 46
- cur = result + 1
-
- i = index(line,tabchar)
- DO while i > 0 & i <= cur - tabadjust
- cur = cur - tabadjust
- i = index(line,tabchar,i+1)
- END
-
- /* If the current character is non-alphabetic, then start one character
- over to the left. This allows the cursor to be immediately after
- the key word (say on a space or bracket.) */
-
- char = substr(line,cur,1)
- if (~(datatype(char,'A') | char = '_') & cur > 1) then
- cur = cur - 1
-
- /* Find leftmost and rightmost alphabetic character adjacent to current: */
-
- right = cur - 1
- left = cur + 1
- char = 'A'
- DO while (datatype(char,'A') | char = '_') & (left > 0)
- left = left - 1
- if left > 0 then
- char = substr(line,left,1)
- END
- char = 'A'
- DO while (datatype(char,'A') | (char = '_'))
- right = right + 1
- char = substr(line,right,1)
- END
-
- if right-left <= 1 then
- DO
- getstring
- target = result
- if (target = 'RESULT') then
- exit
- END
- else
- DO
- target = substr(line,left+1,right-left-1)
- END
-
- DO
- address command 'WBTF'
- say 'Searching for function' target '...'
-
- filename = 'RAM:' || target || '.autodoc'
-
- address command 'GetAutoDoc >' || filename target
- if open('autodocfile',filename) = 0 then
- DO
- cedtofront
- okay1 'Could not find "GetAutoDoc".'
- exit
- END
- else
- DO
- line = readln('autodocfile')
- call close 'autodocfile'
-
- if left(line,1) = '-' then
- DO
- address command 'delete' filename
- cedtofront
- okay1 substr(line,3)
- exit
- END
- else
- DO
- /* If we have a help file displayed, use its window,
- else open a new one: */
-
- helpfile = getclip('HelpWindow')
- /* Get name of current file */
- status 21
- if helpfile ~= result then
- DO
- /* Find out how many views are displayed */
- status 66
-
- /* Try to find the view containing the help file */
- DO numwins=result-1 to 1 by -1 until result = helpfile
- next view
- /* Get name of current file */
- status 21
- END
- END
-
- /* If we can't find the file, then ask to open it */
- if result ~= helpfile then
- DO
- next view /* bring back to original view */
- open new
- END
- else
- DO
- /* Only replace this file if there have been no
- changes. Get number of changes: */
- status 18
- if result ~= 0 then
- DO
- next view
- open new
- END
- END
-
- cedtofront
- /* Set tab size to eight: */
- menu 2 1 7
- open filename
-
- /* Save file name of the Help Window */
- status 21
- call setclip 'HelpWindow',result
- END
- address command 'delete' filename
- END
- END
- exit
-