home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / e / epmmac2.zip / KWHELP.E < prev    next >
Text File  |  1992-08-18  |  3KB  |  112 lines

  1. /* format of index file:
  2.      (Win*, view winhelp.inf ~)
  3.      (printf, view edchelp.inf printf)
  4. */
  5.  
  6. defc kwhelp=  call pHelp_C_identifier()
  7.  
  8. defproc pHelp_C_identifier
  9.    universal helpindex_id
  10.    if not find_token(startcol, endcol) then
  11.       return
  12.    endif
  13.    identifier = substr(textline(.line), startcol, (endcol-startcol)+1)
  14.  
  15.    getfileid CurrentFile             /* save the ID of the current file */
  16.    if helpindex_id then
  17.       display -2
  18.       rc = 0
  19.       activatefile helpindex_id
  20.       display 2
  21.       if rc then  -- File's gone?
  22.          helpindex_id = 0
  23.       endif
  24.    endif
  25.    if not helpindex_id then
  26.       helplist = Get_Env('HELPNDX')
  27.       if helplist='' then
  28. compile if defined(KEYWORD_HELP_INDEX_FILE)
  29.          helplist = KEYWORD_HELP_INDEX_FILE
  30. compile else
  31.          helplist = 'epmkwhlp.ndx'
  32. compile endif
  33.       endif
  34.       ft = filetype()
  35.       savelist = helplist
  36.       do while helplist<>''
  37.          parse value helplist with helpindex '+' helplist
  38.  
  39.          /* look for the help index file in current dir, EPMPATH, DPATH, and EPM.EXE's dir: */
  40.          findfile destfilename, helpindex, '','D'
  41.  
  42.          if rc then
  43.             /* If that fails, try the standard path. */
  44.             findfile destfilename, helpindex, 'PATH'
  45.             if rc then
  46.                sayerror  'Help index 'helpindex' not found'
  47.                return
  48.             endif
  49.          endif
  50. compile if EVERSION >='5.50'
  51.          if pos(' ',destfilename) then
  52.             destfilename = '"'destfilename'"'
  53.          endif
  54. compile endif
  55.          if helpindex_id then
  56.             bottom
  57.             last = .last
  58.             'get' destfilename
  59.             line = upcase(textline(last+1))
  60.             if word(line,1)='EXTENSIONS:' & wordpos(ft, line) then  -- Move to top
  61.                call psave_mark(savemark)
  62.                call pset_mark(last+1, .last, 1, MAXCOL, 'LINE', helpindex_id)
  63.                0
  64.                move_mark
  65.                call prestore_mark(savemark)
  66.             endif
  67.          else
  68.             'xcom e /d' destfilename
  69.             getfileid helpindex_id
  70.             .visible = 0
  71.          endif
  72.       enddo
  73.       helpindex_id.userstring = savelist
  74.    endif
  75.    top; .col = 1
  76.  
  77.  
  78.    display -2
  79.    getsearch savesearch
  80.    'xcom /('identifier',/'     -- search for the exact match...
  81.    if rc then
  82.       do i = length(identifier) to 0 by -1
  83.          'xcom /('leftstr(identifier, i)'*,/'
  84.          if not rc then
  85.             leave
  86.          endif
  87.       enddo
  88.    endif
  89.    setsearch savesearch
  90.    display 2
  91.  
  92.    if rc then
  93.       sayerror 'Unable to find entry for 'identifier' in 'helpindex_id.userstring'.'
  94.    else
  95.       parse value substr(textline(.line), .col) with ',' line ')'
  96.       /* substitute all occurrances of '~' with the original identifier */
  97.       loop
  98.          i = pos('~', line)
  99.          if not i then
  100.             leave
  101.          endif
  102.          line = leftstr(line, i-1)||identifier||substr(line, i+1)
  103.       endloop
  104.  
  105.       if upcase(word(line,1))='VIEW' then
  106.          sayerror 'Invoking View ...'
  107.       endif
  108.       'dos 'line  -- execute the command
  109.    endif
  110.    activatefile CurrentFile
  111.  
  112.