home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / ALT_1.E next >
Text File  |  1995-07-14  |  27KB  |  684 lines

  1. --          (Alt-1.e should be renamed alt_1.e for CD-ROM...)
  2. -- Alt-One.E   Bells & whistles for the Alt-1 key.   Bryan Lewis  03/08/87
  3. --
  4. -- I use the Alt-1 key a lot, to edit the file named in the current text line.
  5. -- Very handy along with the commands LIST and SCAN, and with source code.
  6. -- I've jazzed it up so I can hit it when working with:
  7. --
  8. --   1. Lists output by SCAN.COM (see SCAN.E), in the form:
  9. --        --- c:\e3\mykeys.e    3/4/87 1:04p  21136 ---
  10. --   2. E3 source which contains lines like:
  11. --        include 'colors.e'
  12. --   3. C source which contains lines like:
  13. --        #include <dos.h>
  14. --   4. Any old list of filenames to which I've added comments.
  15. --      All text after the filename is ignored.
  16. --   5. Cross-reference lists output by C-USED.
  17. --   6. File lists from the host.
  18. --   7. Lists output by GREP with filenames like "File #0==> CKEYSEL.E <==".
  19. --
  20. --- History, latest change first ----------------------------------------------
  21. --
  22. -- Modified 11/10/88 by TJR:  ALT-ONE may be used to load a file
  23. -- specified by H:*PROCS INDEX (currently only E3PROCS INDEX).  The
  24. -- file will be loaded, and the cursor moved to the line containing
  25. -- the macro of interest.  This is lightning fast once the files
  26. -- are in the ring, and is the perfect tool for anyone who looks through
  27. -- E3PROCS.  When is EOS2PROCS INDEX coming out?  You guys in aisle
  28. -- 32 better keep the same format :-).
  29. --
  30. -- Modified 11/09/88 by TJR:  ALT-ONE will now work even better with
  31. -- the output of GREP.E by TJR.  If the current line of the .grep
  32. -- file is a file listing (see number 7 above), then pressing ALT-1
  33. -- will open the specfied file for editing.  If the current line is
  34. -- not a file specification, then it must be a line within the previous
  35. -- file specified.  If this is the case, then that file will be opened,
  36. -- and the cursor moved to the line specified in the file.  The current
  37. -- line of the new file will be highlighted for quick recognition.
  38. -- Many thanks to Bryan Lewis for all his help.
  39. --
  40. -- Modified 8/9/88 by jbl:  Alt-One will search along a user-specified path.
  41. -- You need this if you usually store your include files somewhere other than
  42. -- the current directory.  I borrowed code from the USE_APPEND feature of
  43. -- standard E (by Ken Kahn, Larry Margolis, and me).
  44. --
  45. -- This is good for editing C or E programs when the include files lie in a
  46. -- different directory, for example:
  47. --
  48. --    #include "foo.e"
  49. --
  50. -- Alt-One will look first in the current directory and then along the path
  51. -- specified by the ESEARCH environmewnt variable.  For instance, you might do:
  52. --
  53. --    C> set esearch=c:\current\et;d:\old\include
  54. --
  55. -- A special feature for C programmers:  If you turn on the constant C_INCLUDE,
  56. -- filenames enclosed in angle brackets will not be looked for in the current
  57. -- directory but along the path specified by the INCLUDE environment variable.
  58. --
  59. -- The ESEARCH feature works for any list of filenames, not just source code.
  60. --
  61. -------------------------------------------------------------------------------
  62. -- Modified 10/19/87 by Chris Codella to handle tryincludes and includes not
  63. -- starting in column 1, and includes with imbedded blanks.  10/19/87
  64. -------------------------------------------------------------------------------
  65. -- Modified by Bryan Lewis to handle lines in a cross-reference listing
  66. -- produced by C-USED, resembling:
  67. --
  68. --   statement                               36 STAT.C
  69. --     1 stat                                31 MAIN.C
  70. --
  71. -- If I press Alt-1 on the first line I want to edit STAT.C and search for the
  72. -- word "statement".  For the second line I want to edit MAIN.C and search for
  73. -- "stat" (the containing function) and then "statement".  I don't trust the
  74. -- line numbers to stay constant.
  75. -- I turn on this feature if the filetype is "USE" or "XRF".
  76. -------------------------------------------------------------------------------
  77.  
  78. -- For linking:  To make this separately compilable, we set the constants we
  79. -- need to check the same way they would be set if we were included in E.EX.
  80. compile if not defined(SMALL)        -- If compiling stand-alone,
  81.   tryinclude 'mycnf.e'                 -- Include user's configuration
  82. const
  83.    E3      = EVERSION < 4
  84.    EOS2    = EVERSION >= 4 & EVERSION < 5
  85.    EOS2FAM = EVERSION >= 4 & EVERSION < '4.10'
  86.    EPM     = EVERSION >= 5
  87.    EPM32   = EVERSION >= 6
  88.  
  89.   compile if not defined(USE_APPEND)   -- because we need these variables
  90.   USE_APPEND = 0                       -- and this sets them properly.
  91.   compile endif
  92.   compile if not defined(HOST_SUPPORT)
  93.   HOST_SUPPORT = 'STD'
  94.   compile endif
  95.   compile if HOST_SUPPORT='STD' | HOST_SUPPORT=''
  96.    compile if not defined(HOSTDRIVE)
  97.       HOSTDRIVE= 'H:'
  98.    compile endif
  99.   compile endif
  100.   compile if not defined(WANT_SEARCH_PATH)
  101.   WANT_SEARCH_PATH = 0
  102.   compile endif
  103.   compile if not defined(WANT_GET_ENV)
  104.     compile if E3
  105.   WANT_GET_ENV = 0
  106.     compile else
  107.   WANT_GET_ENV = 1
  108.     compile endif
  109.   compile endif
  110.   compile if not defined(EPATH)
  111.     compile if EPM  -- EPM uses a different name, for easier coexistance
  112.   EPATH= 'epmpath'
  113.     compile else
  114.   EPATH= 'epath'
  115.     compile endif
  116.   compile endif
  117.   compile if EVERSION >= '4.11' & EVERSION < 5   -- new in EOS2
  118.    compile if not defined(SHELL_USAGE)
  119.   SHELL_USAGE = 1
  120.    compile endif
  121.   compile else
  122.   SHELL_USAGE = 0
  123.   compile endif
  124.   compile if not defined(WANT_EPM_SHELL) or EVERSION < '5.20'
  125.   WANT_EPM_SHELL = 0
  126.                            /* Specifies whether support should be included   */
  127.                            /* for a shell window.                            */
  128.   compile endif
  129.   compile if not defined(NLS_LANGUAGE)
  130.     NLS_LANGUAGE = 'ENGLISH'
  131.   compile endif
  132.   include NLS_LANGUAGE'.e'
  133.   compile if not defined(DIRECTORYOF_STRING)
  134. ; DIRECTORYOF_STRING = 'Directory of'  -- Since we're now including ENGLISH.E, ...
  135.   DIRECTORYOF_STRING = DIR_OF__MSG
  136.   compile endif
  137. compile endif
  138.  
  139. const                             -- These are Alt-1.e -specific constants.
  140.   compile if not defined(AltOnePathVar)
  141.    AltOnePathVar= 'ESEARCH'    -- the name of the environment variable
  142.   compile endif
  143.   compile if not defined(C_INCLUDE)
  144.    C_INCLUDE    = 1            -- 1 means search <filename> along INCLUDE path
  145.   compile endif
  146.  
  147. define
  148.    QUOTED_DIR_STRING ='"'DIRECTORYOF_STRING'"'
  149.  
  150.  
  151. def a_1=
  152.    universal host_LT                    -- Used with LAMPDQ.E
  153. compile if HOST_SUPPORT='EMUL' or HOST_SUPPORT='SRPI'
  154.    universal hostdrive
  155. compile endif
  156.    /* edit filename on current text line */
  157.    getline line
  158.    orig_line = line
  159.  
  160. compile if (EVERSION >= '4.12' & EVERSION < 5 & SHELL_USAGE) | WANT_EPM_SHELL
  161.  compile if EOS2
  162.    if .filename = '.SHELL' then
  163.  compile else
  164.    if leftstr(.filename, 15) = ".command_shell_" then
  165.  compile endif
  166.       if substr(line, 13, 1) = ' ' then  -- old format DIR, or not a DIR line
  167.          flag = substr(line, 1, 1) <> ' ' &
  168.                 (isnum(substr(line, 14, 8)) | substr(line, 14, 8)='<DIR>') &
  169.                 length(line) < 40 &
  170.                 isnum(substr(line, 24, 2) || substr(line, 27, 2) || substr(line, 30, 2)) &
  171.                 substr(line, 26, 1) = substr(line, 29, 1) &
  172.                 pos(substr(line, 26, 1), '/x.-')
  173.          filename=strip(substr(line,1,8))
  174.          word2=strip(substr(line,10,3))
  175.          if word2<>'' then filename=filename'.'word2; endif
  176.       else                               -- new format DIR, or not a DIR line
  177.          flag = substr(line, 41, 1) <> ' ' &
  178.                 (isnum(substr(line, 18, 9)) | substr(line, 18, 9)='<DIR>') &
  179.                 isnum(substr(line, 1, 2) || substr(line, 4, 2) || substr(line, 7, 2)) &
  180.                 substr(line, 3, 1) = substr(line, 6, 1) &
  181.                 pos(substr(line, 3, 1), '/x.-')
  182.          filename=substr(line,41)
  183.       endif
  184.       if flag then
  185.          call psave_pos(save_pos)
  186.          getsearch oldsearch
  187.  compile if EPM
  188.          display -2
  189.  compile endif
  190.          'xcom l /'DIRECTORYOF_STRING'/c-'
  191.          dir_rc = rc
  192.          if not rc then
  193.             getline word3
  194.             parse value word3 with $QUOTED_DIR_STRING word3 .
  195. ;;          parse value word3 with . . word3 .
  196.             if verify(word3,'?*','M') then  -- If wildcards - must be 4OS2 or similar shell
  197.                word3 = strip(substr(word3, 1, lastpos(word3, '\')-1))
  198.             endif
  199.  compile if EOS2
  200.          else
  201.             sayerror 1
  202.  compile endif
  203.          endif
  204.  compile if EPM
  205.          display 2
  206.  compile endif
  207.          setsearch oldsearch
  208.          call prestore_pos(save_pos)
  209.          if not dir_rc then
  210.             name=word3 ||                            -- Start with the path.
  211.                  leftstr('\',                        -- Append a '\', but only if path
  212.                          '\'<>rightstr(word3,1)) ||  -- doesn't end with one.
  213.                  filename                            -- Finally, the filename
  214.  compile if EPM
  215. ;           if pos(' ',name) then  -- enquote
  216.             if verify(name, ' =', 'M') then  -- enquote
  217.                name = '"'name'"'
  218.             endif
  219.  compile endif
  220.             if pos('<DIR>',line) then
  221.                'dir 'name
  222.             else
  223.                'e 'name
  224.             endif
  225.             return
  226.          endif
  227.       endif
  228.    endif
  229. compile endif  -- SHELL_USAGE | WANT_EPM_SHELL
  230.  
  231.    -- jbl 2/14/89:  we now distribute a standard front end for the DIR
  232.    -- command, which redirects the output to a file named ".dos dir <dirname>".
  233.    -- lam 3/15/89:  added code to handle trailing blanks and wildcards.
  234.    -- Previously, after a 'DIR \path\*.E ', would do:  E \path\*.E \fname.ext
  235.    parse value .filename with word1 word2 word3 .
  236.    if upcase(word1 word2) = '.DOS DIR' then
  237.       call psave_pos(save_pos)
  238. compile if EVERSION >= '4.12'
  239.       getsearch oldsearch
  240. compile endif
  241.       'xcom l /'DIRECTORYOF_STRING'/c-'
  242.       if not rc then
  243.          getline word3
  244.          parse value word3 with . . word3 .
  245.          if verify(word3,'?*','M') then  -- If wildcards - must be 4OS2 or similar shell
  246.             word3 = strip(substr(word3, 1, lastpos(word3, '\')-1))
  247.          endif
  248.       endif
  249. compile if EVERSION >= '4.12'
  250.       setsearch oldsearch
  251. compile endif
  252.       call prestore_pos(save_pos)
  253. compile if EVERSION >= 4  -- DOS (box) doesn't see new-format DIR listing
  254.       filename=substr(line,41)                 -- Support HPFS.  FAT dir's end at 40
  255.       if filename='' then                      -- Must be FAT.
  256. compile endif
  257.          filename=strip(substr(line,1,8))
  258.          word2=strip(substr(line,10,3))
  259.          if word2<>'' then filename=filename'.'word2; endif
  260. compile if EVERSION >= 4  -- DOS (box) doesn't see new-format DIR listing
  261.       endif
  262. compile endif
  263.       name=word3 ||                            -- Start with the path.
  264. compile if EVERSION >= '5.17'
  265.            leftstr('\',                        -- Append a '\', but only if path
  266.                    '\'<>rightstr(word3,1)) ||  -- doesn't end with one.
  267. compile else
  268.            substr('\', 1,                      -- Append a '\', but only if path
  269.                   '\'<>substr(word3,length(word3),1)) ||  -- doesn't end with one.
  270. compile endif
  271.            filename                            -- Finally, the filename
  272. compile if EPM
  273. ;     if pos(' ',name) then  -- enquote
  274.       if verify(name, ' =', 'M') then  -- enquote
  275.          name = '"'name'"'
  276.       endif
  277. compile endif
  278.       if pos('<DIR>',line) then
  279.          'dir 'name
  280.       else
  281. ;        call a1load(name,AltOnePathVar,0)
  282.          'e' name
  283.       endif
  284.       return
  285.    endif
  286. ;compile if EPM32
  287.    if .filename = '.tree' then
  288.       if substr(line,5,1)substr(line,8,1)substr(line,15,1)substr(line,18,1) = '--::' then
  289.          name = substr(line, 52)
  290.          if substr(line,31,1)='>' then
  291.             if isadefc('tree_dir') then
  292.                'tree_dir "'name'\*.*"'
  293.             else
  294.                'dir' name
  295.             endif
  296.          else
  297. compile if EVERSION >= '5.50'
  298.             'e "'name'"'
  299. compile else
  300.             'e' name
  301. compile endif
  302.          endif
  303.       endif
  304.       return
  305.    endif
  306. ;compile endif
  307.  
  308.    -- jbl 11/15/88:  replace any '/' with '\'.  C compiler error output
  309.    -- can have forward slashes.
  310.    p=pos('/',line)
  311.    while p>0 do
  312.       line=substr(line,1,p-1)'\'substr(line,p+1)
  313.       p=pos('/',line)
  314.    endwhile
  315.    -- jbl 11/15/88:  The C compiler error line can have a line number in
  316.    -- parentheses, like "/epm/i/iproto.h(196)".  Get the number.
  317.    linenum=''; col = ''
  318.    p=pos('(',line)
  319.    if p>0 then
  320.       parse value line with line '(' linenum ')' .
  321.       parse value linenum with linenum ':' col  -- LAM: CSet/2 includes column
  322.    endif
  323.  
  324. /******************************************************************************/
  325. /***       LAMPDQ support for LISTFILE output                               ***/
  326. /******************************************************************************/
  327. compile if HOST_SUPPORT
  328.    -- 5/11/88:  make Alt-1 work on lists of host files. */
  329.    -- This works best with Larry Margolis's PDQ support (SLPDQ), and only
  330.    -- when the name of the list file is "LIST OUTPUT", as is true when
  331.    -- I'm using LaMail.  I have to have some way of knowing it's a list
  332.    -- of host files.
  333. ;; if .filename ="LIST OUTPUT" then
  334.    -- 10/21/88 (LAM): Make work for any abbreviation of LISTFILE, not just
  335.    -- LIST, and ignore extra spaces on left and info on right [e.g., output
  336.    -- from LISTFILE (ALLOC ].
  337.    parse value .filename with file ext .
  338.    if ext='OUTPUT' & file=substr('LISTFILE',1,length(file)) then
  339.       parse value line with fn ft fm .
  340. compile if EPM
  341.       parse value .userstring with '[lt:'lt']'
  342.       if lt='' then lt=host_lt; endif
  343.       'e 'substr(hostdrive,1,1) || lt':'fn ft fm
  344. compile else
  345.       'e 'substr(hostdrive,1,1) || host_lt':'fn ft fm
  346. compile endif -- EPM
  347.       return
  348.    endif
  349. compile endif  -- HOST_SUPPORT
  350.  
  351. /******************************************************************************/
  352. /***       LaMail index support                                             ***/
  353. /******************************************************************************/
  354. compile if EPM
  355.    if upcase(rightstr(.filename, 4))='.NDX' then
  356. compile else
  357.    if filetype()='NDX' then
  358. compile endif -- EPM
  359.       parse value orig_line with 28 fn ft . 84 ext
  360.       if pos(\1, ext) then
  361.          'e' substr(.filename, 1, length(.filename)-4)'\'fn'.'ft
  362.          return
  363.       endif
  364.    endif
  365.  
  366. /******************************************************************************/
  367. /***       C-USED support                                                   ***/
  368. /******************************************************************************/
  369.  
  370.    -- If the filetype is USE or XRF, do C-USED feature.
  371.    ext=substr(upcase(.filename),lastpos('.',upcase(.filename))+1)
  372.    if ext='USE' or ext='XRF' then
  373.       if substr(line,1,1)=' ' then  -- child line
  374.          parse value line with . infunc linenum file
  375.          for i = .line-1 to 1 by -1   -- search upward for parent line
  376.             getline line,i
  377.             if substr(line,1,1) <> ' ' then
  378.                parse value line with func .
  379.                leave
  380.             endif
  381.          endfor
  382.          call a1load(file,AltOnePathVar,1)
  383.          top
  384.          'L /'infunc; if rc then return; endif
  385.          'L /'func;   if rc then return; endif
  386.          sayerror 'Found 'func' in 'infunc' in 'file'.'
  387.       else                          -- parent line
  388.          parse value line with func linenum file
  389.          if linenum='#' then        -- might have a '#' in 2nd column
  390.             parse value file with linenum file
  391.          endif
  392.          call a1load(file,AltOnePathVar,1)
  393.          top
  394.          'L /'func; if rc then return; endif
  395.          sayerror 'Found 'func' in 'file'.'
  396.       endif
  397.       return
  398.    endif    -- C-USED feature
  399.  
  400. /******************************************************************************/
  401. /***       E3PROCS index support                                            ***/
  402. /******************************************************************************/
  403.  
  404.    -- 11/10/88: Load Files Directly From The INDEX File.  By TJR
  405.    --           Now loads files from the E3PROCS INDEX hostfile.  It is
  406.    --           assumed that someday there will be an EOS2PROCS INDEX of
  407.    --           the same format, therefore this macro was written to
  408.    --           look for any H:*PROCS INDEX file.  A sincere attempt is
  409.    --           made to open the file and move to the macro of interest.
  410. compile if HOST_SUPPORT
  411.    fn = .filename
  412.    parse value .filename with filename filetyp fmode .  -- Not as crude, TJR
  413.  compile if EPM
  414.    if ('INDEX'=filetyp & 'PROCS'=rightstr(filename, 5) &
  415.  compile else
  416.    if ('INDEX'=filetyp & 'PROCS'=substr(filename, max(length(filename)-4,1), 5) &
  417.  compile endif
  418.         vmfile(fn,ft)) then
  419.       parse value line with proc fn ft uid node date .
  420.       if ('PROCS'<>ft) then                   -- Is the current line an entry?
  421.          getline line, .line-1                -- Go back one line and try again.
  422.          parse value line with proc fn ft uid node date .
  423.          if ('PROCS'<>ft) then                -- One more time. . . .
  424.             sayerror'Sorry, cursor is not at a PROCS index entry!  No file loaded!'
  425.             return
  426.          endif
  427.       endif                                   -- If we're here, must be an entry!
  428.  compile if HOST_SUPPORT='EMUL' or HOST_SUPPORT='SRPI'
  429.       if substr(.filename, 3, 1)=':' then
  430.          lt = substr(.filename, 2, 1)
  431.       else
  432.          lt = host_lt
  433.       endif
  434.       'e' hostdrive || lt':'fn ft fmode
  435.  compile else
  436.       'e' HOSTDRIVE || fn ft fmode
  437.  compile endif
  438.       top                                     -- Goto top of file.
  439.       do forever
  440.  compile if EVERSION >= '4.12'
  441.          getsearch oldsearch
  442.  compile endif
  443.          'xcom l ₧'date'₧'                    -- Try to get the procedure.
  444.  compile if EVERSION >= '4.12'
  445.          setsearch oldsearch
  446.  compile endif
  447.          if rc then
  448.             sayerror proc' macro added by 'uid' on 'date' was not found!'
  449.             TOP                               -- Go back to the top.
  450.             BEGINLINE                         -- Move to beginning.
  451.             return
  452.          else
  453.             getline line
  454.             if (uid = substr(line, lastpos('by ', line)+3, length(uid))) then
  455.                sayerror proc' macro added by 'uid' on 'date
  456.                BEGINLINE                      -- Move to beginning.
  457.                return
  458.             else
  459.                '+1'
  460.             endif
  461.          endif
  462.       enddo
  463.    endif
  464.    -- End of TJR's INDEX file modifications.
  465. compile endif  -- HOST_SUPPORT
  466.  
  467. /******************************************************************************/
  468. /***       GREP support                                                     ***/
  469. /******************************************************************************/
  470.  
  471.    -- 8/10/88:  Handle GREP output like "File #0==> CKEYSEL.E <==".
  472.    parse value line with "==>" filename "<=="
  473.    if filename then
  474.       call a1load(filename,AltOnePathVar,1)
  475.       return
  476.    endif
  477.  
  478.    -- 11/03/88: Open file specified by GREP and move to current line!  TJR
  479.    -- Use the name ".grep" as the signature, so I can load multiple grep lists.
  480.    -- See GREP.E.  jbl.
  481.    if substr(.filename,1,5)=".grep" |                            -- TJR's GREP
  482.       substr(.filename,1,17)=".Output from grep" then            -- LAM's GREP
  483. compile if EVERSION >= '4.12'
  484.          getsearch oldsearch
  485. compile endif
  486.        call psave_pos(save_pos)
  487.        'xcom l .   File #. -'          /* Find previous file           */
  488. compile if EVERSION >= '4.12'
  489.          setsearch oldsearch
  490. compile endif
  491.        if rc then
  492.           sayerror 'No files found!'
  493.           return
  494.        else
  495.           getline newline
  496.           call prestore_pos(save_pos)
  497.           parse value newline with "==> " filename " <=="
  498.           call a1load(filename,AltOnePathVar,1)
  499. ;;compile if 1                                                -- LAM:  I use /L
  500. ;  Now supports both; if line starts with a number, assume /L; if not, do search.
  501.           parse value orig_line with num ')'
  502.           if pos('(', num) & not pos(' ', num) then
  503.              parse value num with . '(' num
  504.           endif
  505.           parse value num with num ':' col
  506.           if isnum(num) then
  507.              .cursory=.windowheight%2
  508.              num
  509.              if isnum(col) then .col = col; endif
  510.              return
  511.           endif
  512. ;;compile else                                                -- TJR doesn't
  513.           parse value orig_line with "==>" tempstr
  514.           if  tempstr = ''  then
  515.  compile if defined(HIGHLIGHT_COLOR)  -- Let it be hilighted by the built-in stuff...
  516.              'l ₧'orig_line'₧eaf+'          /* ALT-158 is the search delim */
  517.  compile else
  518.              'xcom l ₧'orig_line'₧'         /* ALT-158 is the search delim */
  519.  compile endif
  520.              if rc then
  521.                  sayerror substr(line, 1, 60)'. . . Not Found!'
  522.  compile if not defined(HIGHLIGHT_COLOR)
  523.              else
  524.                  refresh
  525.                  unmark
  526.                  mark_block            /* hilite the line with string  */
  527.                  end_line
  528.                  mark_block
  529.                  begin_line
  530.  compile endif
  531.              endif
  532.           endif
  533.           return
  534. ;;compile endif
  535.        endif
  536.    endif
  537.    -- End of TJRs 11/03/88 Modifications!
  538.  
  539.    if substr(.filename,1,17)=".Output from gsee" then            -- LAM's GSEE
  540.       parse value line with name '.' ext 13 52 path
  541.       if substr(line,9,1)='.' & substr(line,53,1)=':' then
  542.          if length(path) > 3 then path = path'\'; endif
  543.          call a1load(path || strip(name)'.'ext,AltOnePathVar,0)
  544.          return
  545.       endif
  546.    endif
  547.  
  548.  
  549.    /** If line starts with 'include' or '#include', read the filename. **/
  550.    pathvar = AltOnePathVar      -- default, if not #include <>
  551.    TryCurFirst=1
  552.    -- jbl 10/25/88:  don't accept "include" anywhere in the line, you'll be
  553.    -- fooled by path names like c:\c\include.  Accept it only as first word.
  554.    -- inclpos=pos('include',lowcase(line))
  555.    parse value lowcase(line) with word1 word2 .
  556.    if word1="include" or word1="#include" or word1="tryinclude" then
  557.       delim=substr(word2,1,1)
  558.       if delim="'" | delim='"' then
  559.          call a1load(strip(word2,'B',delim),EPATH,1)    /* For E files */
  560.       elseif delim='<' then
  561.          parse value word2 with '<'word2'>'
  562.          -- jbl 10/25/88:  Searching only along the INCLUDE path didn't always
  563.          -- work.  Rechecking the C compiler manual, I see that it first
  564.          -- searches the specified search path (i.e., what we call ESEARCH) and
  565.          -- then the "standard directories", the INCLUDE path.
  566.          call a1load(word2,PathVar,TryCurFirst)  -- So first search ESEARCH.
  567. compile if C_INCLUDE
  568.          -- If that fails, try INCLUDE path.
  569.          if rc=sayerror("New file") or rc=sayerror("Path not found") then
  570.             'q'
  571.             pathvar='INCLUDE'
  572.             TryCurFirst=0
  573.             call a1load(word2,PathVar,TryCurFirst)
  574.          endif
  575. compile endif
  576.       endif
  577.       line=''  -- Don't try to load "INCLUDE" !
  578.    else
  579.       /** If line starts with fillers (duplicate characters and a space) like: **/
  580.       /**   --- FOOBAR.TXT    (which is from SCAN), strip them off.  JBL       **/
  581.       c=substr(line,1,1)
  582.       temp = strip(line,'L',c)
  583.       /* Must be a space after the fillers, and more than one filler. */
  584.       if substr(temp,1,1)=' ' and length(temp)<length(line)-1 then
  585.          line=temp          --LAM: Leading blank will be stripped by Parse, below.
  586.       endif
  587.       /**  end of strip-leading-fillers modification  **/
  588.    endif
  589.  
  590.    if line<>'' then
  591.       /* also discard remainder of line after the first word, so I can comment */
  592.       parse value line with line .
  593.       call a1load(line,PathVar,TryCurFirst)
  594.    endif
  595.    linenum  -- jbl 11/15/88, go to specified linenum if any.
  596.    if col <> '' then .col = col; endif
  597.  
  598.  
  599. defproc a1load(filename,PathVar,TryCurFirst)
  600.    if pos('*', filename) then
  601.       if YES_CHAR<>askyesno(WILDCARD_WARNING__MSG, '', filename) then
  602.          return
  603.       endif
  604.    endif
  605.    if TryCurFirst then
  606.       if exist(filename) then
  607.          'e' filename
  608.          return
  609.       endif
  610.    endif
  611.    'e' search_path(Get_Env(PathVar),filename)filename
  612.  
  613. compile if not (USE_APPEND | WANT_SEARCH_PATH)  -- This might already be included in user's E.
  614. defproc search_path(AppendPath, FileName)
  615.    do while AppendPath<>''
  616.       parse value AppendPath with TryDir ';' AppendPath
  617.       if trydir='' then iterate; endif
  618. compile if EVERSION >= '5.17'
  619.       lastch=rightstr(TryDir,1)
  620. compile else
  621.       lastch=substr(TryDir,length(TryDir),1)
  622. compile endif
  623.       if lastch<>'\' & lastch<>':' then
  624.          TryDir = TryDir||'\'
  625.       endif
  626.       if exist(TryDir||FileName) then
  627.          return TryDir
  628.       endif
  629.    enddo
  630.    return ''
  631. compile endif
  632.  
  633. compile if not (USE_APPEND | WANT_GET_ENV)  -- This might already be included in user's E.
  634. defproc get_env(varname)=
  635.    varname = upcase(varname)
  636.    env_ofs = 0
  637. compile if EVERSION>=4
  638.  compile if EVERSION<'4.10'     -- If no more family mode, don't check machine()
  639.    if machine()='OS2PROTECT' then
  640.  compile endif
  641.       seg_ptr = 1234
  642.       cmd_ptr = 1234
  643.       call dynalink('DOSCALLS',
  644.                     '#91',
  645.                     selector(seg_ptr) ||
  646.                     offset(seg_ptr)   ||
  647.                     selector(cmd_ptr) ||
  648.                     offset(cmd_ptr)     )
  649.       env_seg=itoa(seg_ptr,10)
  650.  compile if EVERSION<'4.10'     -- If no more family mode, don't check machine()
  651.    else
  652.  compile endif
  653. compile endif
  654. compile if EVERSION<'4.10'
  655.       if dos_version() < 300 then
  656.          sayerror 'DOS version 3.0 or above required for Get_Env Address.'
  657.          return ''
  658.       endif
  659.       parse value int86x(33,25088,'') with . PSP_seg .  -- Int 21H, AH=62H
  660.       env_seg = asc(peek(PSP_seg,45,1)) * 256 + asc(peek(PSP_seg,44,1))
  661.  compile if EVERSION>='4.02'
  662.    endif
  663.  compile endif
  664. compile endif
  665.    do while peek(env_seg,env_ofs,1) /== \0  -- (backslash) 0 == ASCII null
  666. compile if EVERSION < '5.17'
  667.       start = env_ofs
  668.       do while peek(env_seg,env_ofs,1) /== \0
  669.          env_ofs = env_ofs + 1
  670.       end
  671.       setting = peek(env_seg,start,env_ofs-start)
  672. compile else
  673.       setting = peekz(env_seg,env_ofs)
  674. compile endif
  675.       parse value setting with name '=' parameter
  676.       if name=varname then return parameter; endif
  677. compile if EVERSION < '5.17'
  678.       env_ofs=env_ofs+1
  679. compile else
  680.       env_ofs=env_ofs+length(setting)+1
  681. compile endif
  682.    end
  683. compile endif
  684.