home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / e / epmmac2.zip / STDCMDS.E < prev    next >
Text File  |  1992-11-24  |  63KB  |  1,890 lines

  1. ;
  2. ; STDCMDS.E            Alphabetized by command name.
  3. ;
  4.  
  5. compile if EVERSION >=4
  6.  
  7. defc app, append =            -- With linking, PUT can be an external module.
  8.    'put' arg(1)               -- Collect the names; the module is named PUT.EX.
  9. compile else
  10. ;  Put and append work the same, and the same as XEdit's PUT.
  11. ;  If the file already exists, append to it.
  12. ;  If no file is specified, use same file as last specified.
  13. ;  If no mark, use append the entire file.
  14. defc app, append, put =
  15.    universal last_append_file
  16.  
  17.    if arg(1) = '' then
  18.       app_file=last_append_file
  19.    else
  20.       app_file=parse_file_n_opts(arg(1))
  21.       last_append_file=app_file
  22.    endif
  23.    if app_file='' then
  24.       sayerror NO_FILENAME__MSG 'PUT'
  25.       stop
  26.    endif
  27.    getfileid fileid
  28.    if marktype() then
  29.       had_mark = 1
  30.       call psave_mark(save_mark)
  31.       call prestore_mark(save_mark)
  32.    elseif .last = 0 then sayerror FILE_IS_EMPTY__MSG; stop
  33.    else
  34.       had_mark = 0
  35.       call pset_mark(1,.last,1,1,'LINE',fileid)
  36.    endif
  37.    /* If file is already in memory, we'll leave it there for speed. */
  38.    parse value 1 check_for_printer(app_file) with already_in_ring is_printer .
  39.    is_console = upcase(app_file)='CON' | upcase(app_file)='CON:'
  40.    if is_printer | is_console then
  41.       'e /q /n 'app_file
  42.    else
  43.       'e /q /n' app_file   /* look for file already in ring */
  44.       if rc=-282 then  -- -282 = sayerror("New file")
  45.          already_in_ring = 0
  46.          'q'
  47.          'e /q' app_file  /* not 'xcom e', so we can append to host files */
  48.       endif
  49.    endif
  50.    if is_printer or is_console or not already_in_ring then
  51.       if rc=-282 then
  52.          deleteline
  53.       elseif rc then
  54.          stop
  55.       endif
  56.    endif
  57.    getfileid tempofid
  58.    if marktype()<>'LINE' then
  59.       insertline '',tempofid.last+1
  60.    endif
  61.    bottom
  62.    copyrc=pcopy_mark()
  63.    if copyrc then /* Check memory full, invalid path, etc. */
  64.       .modify=0; 'q'
  65.       sayerror copyrc
  66.       stop
  67.    endif
  68.    aborted=0
  69.    /* If the app_file was already in memory, don't file it. */
  70.    if is_printer or is_console or not already_in_ring then
  71.       if is_console then say ''; endif
  72.       'save'
  73.       if is_console then pause; endif
  74.       aborted=rc
  75.       activatefile tempofid; tempofid.modify=0; 'q'
  76.    endif
  77.    activatefile fileid
  78.    if had_mark then
  79.       call prestore_mark(save_mark)
  80.    else
  81.       unmark
  82.    endif
  83.    if not aborted then
  84.       sayerror MARK_APPENDED__MSG app_file
  85.    endif
  86. compile endif
  87.  
  88. defc asc=
  89.    parse arg i '=' .
  90.    if i='' then
  91.       getline line
  92.       i=substr(line,.col,1)
  93.    endif
  94. compile if EVERSION < 5
  95.    setcommand 'asc 'i'='asc(i)'',5,1
  96.    cursorcommand
  97. compile else
  98.    sayerror 'asc 'i'='asc(i)''
  99. compile endif
  100.  
  101.  
  102. defc autosave=
  103.    universal vAUTOSAVE_PATH
  104. compile if RING_OPTIONAL
  105.    universal ring_enabled
  106. compile endif
  107. compile if E3
  108.    universal autosave
  109. compile endif
  110.    uparg=upcase(arg(1))
  111.    if uparg=ON__MSG then                  /* If only says AUTOSAVE ON,  */
  112. compile if E3
  113.    compile if DEFAULT_AUTOSAVE > 0
  114.       autosave = DEFAULT_AUTOSAVE
  115.    compile else
  116.       autosave = 10                    /* default is every 10 lines. */
  117.    compile endif
  118. compile else
  119.    compile if DEFAULT_AUTOSAVE > 0
  120.       .autosave = DEFAULT_AUTOSAVE
  121.    compile else
  122.       .autosave=10                     /* default is every 10 mods. */
  123.    compile endif
  124. compile endif
  125.    elseif uparg=OFF__MSG then
  126. compile if E3
  127.       autosave = 0
  128. compile else
  129.       .autosave = 0
  130. compile endif
  131.    elseif isnum(uparg) then            /* Check whether numeric argument. */
  132. compile if EVERSION < '4.12'
  133.       autosave = uparg
  134. compile else
  135.       .autosave = uparg
  136. compile endif
  137.    elseif uparg='DIR' then
  138.       'dir' vAUTOSAVE_PATH
  139.    elseif uparg='' then
  140. compile if EPM
  141.       'commandline autosave' .autosave
  142.    elseif uparg='?' then
  143.  compile if RING_OPTIONAL
  144.      if ring_enabled then
  145.  compile endif
  146.  compile if 0
  147.       do forever
  148.          retvalue=winmessagebox(AUTOSAVE__MSG, CURRENT_AUTOSAVE__MSG||.autosave\10||NAME_IS__MSG||MakeTempName()\10\10LIST_DIR__MSG, 24628)  -- YESNO + MB_INFORMATION + MOVEABLE + HELP
  149.          if retvalue<>8 then leave; endif    -- MBID_HELP = 8
  150.          'helpmenu 2045'
  151.       enddo
  152.       if 6=retvalue then  -- MBID_YES
  153.  compile else
  154.       if 6=winmessagebox(AUTOSAVE__MSG, CURRENT_AUTOSAVE__MSG||.autosave\10||NAME_IS__MSG||MakeTempName()\10\10LIST_DIR__MSG, 16436)  -- YESNO + MB_INFORMATION + MOVEABLE
  155.       then
  156.  compile endif
  157.          'dir' vAUTOSAVE_PATH
  158.       endif
  159.  compile if RING_OPTIONAL
  160.      else
  161.         call winmessagebox(AUTOSAVE__MSG, CURRENT_AUTOSAVE__MSG||.autosave\10||NAME_IS__MSG||MakeTempName()\10\10NO_LIST_DIR__MSG, 16432)  -- OK + MB_INFORMATION + MOVEABLE
  162.      endif
  163.  compile endif
  164.       return
  165. compile else  -- not EPM; uparg=''
  166.       cursor_command; begin_line; eraseendline
  167.  compile if E3
  168.       keyin 'autosave' autosave
  169.  compile else
  170.       keyin 'autosave' .autosave
  171.  compile endif
  172. compile endif
  173.    else
  174.       sayerror AUTOSAVE_PROMPT__MSG
  175.       return
  176.    endif
  177. compile if E3
  178.    sayerror CURRENT_AUTOSAVE__MSG||autosave', 'NAME_IS__MSG||MakeTempName()
  179. compile else
  180.    sayerror CURRENT_AUTOSAVE__MSG||.autosave', 'NAME_IS__MSG||MakeTempName()
  181. compile endif
  182.  
  183. ;   autoshell off/on/0/1
  184. ;
  185. ; specifies whether E should automatically pass internally-unresolved commands
  186. ; to DOS.  Autoshell is an internal command; this DEFC is a simple front end
  187. ; to allow the user to type off/on/0/1.  It calls the internal command via
  188. ; 'xcom autoshell'.
  189. ;
  190. ; Users who have very long path-search times might prefer to execute
  191. ; "autoshell 0" somewhere in their start-up sequence.
  192.  
  193. compile if EVERSION < 5
  194. defc autoshell=
  195.    uparg=upcase(arg(1))
  196.    if uparg='ON' or uparg=1 then
  197.       'xcom autoshell 1'
  198.    elseif uparg='OFF' or uparg='0' then
  199.       'xcom autoshell 0'
  200.    else
  201.       sayerror INVALID_ARG__MSG ON_OFF__MSG')'
  202.       stop
  203.    endif
  204. compile elseif EVERSION >= '5.50'
  205. defc autoshell=
  206.    uparg=upcase(arg(1))
  207.    if uparg=ON__MSG or uparg=1 then
  208.       .autoshell = 1
  209.    elseif uparg=OFF__MSG or uparg='0' then
  210.       .autoshell = 0
  211.    else
  212.       sayerror 'AUTOSHELL =' .AUTOSHELL
  213.    endif
  214. compile endif
  215.  
  216. defc bottom,bot=
  217.    bottom
  218.  
  219. compile if EVERSION >='4.11'
  220. ;  BROWSE -- A simple front end to Ralph Yozzo's browse() function.
  221. ;            It allows the user to type off/on/0/1/?.
  222. ;
  223. ;     BROWSE off/on/0/1
  224. ;
  225. ; specifies whether E should allow text to be altered (normal editing mode)
  226. ; or whether all text is read-only.
  227. ;
  228. ; Issuing BROWSE with '?' or no argument returns the current setting.
  229. ;
  230. ; The function browse() takes an optional argument 0/1.  It always returns
  231. ; the current setting.  So you can query the current setting without changing
  232. ; it by giving no argument.
  233. ;
  234. defc browse =
  235.    uparg=upcase(arg(1))
  236.    if uparg=ON__MSG or uparg=1 then
  237.       cb = browse(1)
  238.    elseif uparg=OFF__MSG or uparg='0' then
  239.       cb = browse(0)
  240.    elseif uparg='' or uparg='?' then
  241.       cb = browse()     -- query current state
  242.  compile if EVERSION >= 5
  243.       /* jbl 12/30/88:  move msg to this case only, avoid trivial sayerror's.*/
  244.       sayerror BROWSE_IS__MSG word(OFF__MSG ON__MSG, cb+1)
  245.  compile endif
  246.    else
  247.       sayerror INVALID_ARG__MSG ON_OFF__MSG'/?)'
  248.       stop
  249.    endif
  250.  compile if EVERSION < 5
  251.    if cb then cb=ON__MSG; else cb=OFF__MSG; endif
  252.    sayerror BROWSE_IS__MSG cb
  253.  compile endif
  254. compile endif
  255.  
  256. compile if EVERSION < 4       -- With linking, BOX can be an external module.
  257. ; Ver.3.11:  Don't move cursor for BOX R.
  258. ;  Script style suggested by Larry Salomon, Jr.
  259. defc box=  /* give height width style */
  260.    universal tempofid
  261.  
  262.    uparg=upcase(arg(1))
  263.    msg =  BOX_ARGS__MSG
  264.    if not length(uparg) then
  265.       sayerror msg
  266.       cursor_command;begin_line;erase_end_line;keyin 'Box '
  267.       stop
  268.    endif
  269.    if marktype()<>'BLOCK' then
  270.       sayerror -288  -- 'Block mark required'
  271.       stop
  272.    endif
  273.    flg=0
  274.    for ptr = 1 to length(uparg)
  275.       if flg then
  276.          style=substr(arg(1),ptr,1)
  277.       else
  278.          style=substr(uparg,ptr,1)
  279.       endif
  280.       if style='/' then
  281.          flg=1; iterate
  282.       endif
  283.       if not flg and verify(uparg,"123456BCPAERS") then
  284.          sayerror msg
  285.          cursor_command;begin_line;erase_end_line;keyin 'Box '
  286.          stop
  287.       endif
  288.       call psave_pos(save_pos)
  289.       getmark firstline,lastline,firstcol,lastcol,fileid
  290.       if style='E' then
  291.          getline tline,firstline,fileid
  292.          getline bline,lastline,fileid
  293.          msg=BOX_MARK_BAD__MSG
  294.          if firstcol=1 or firstline=1 or lastline=fileid.last then
  295.             sayerror msg
  296.             stop
  297.          endif
  298.  
  299.          brc=substr(bline,lastcol+1,1)
  300.          lside=substr(tline,firstcol-1,1)
  301.          if lside='║' or lside='│' or lside=';' or lside='|' or lside='█'  then
  302.             sl=1
  303.          elseif lside='*' and firstcol>2 and  -- MAX prevents error if firstcol <= 2
  304.                               pos(substr(tline,max(firstcol-2,1),1),'{/.') then
  305.                sl=2
  306.          elseif brc=lside then
  307.             sl=1
  308.          else
  309.             sayerror msg
  310.             stop
  311.          endif
  312.          for i=firstline to lastline
  313.             getline line,i,fileid
  314.             replaceline substr(line,1,firstcol-sl-1)||substr(line,firstcol,lastcol+1-firstcol)||substr(line,lastcol+sl+1),i,fileid
  315.          endfor
  316.          deleteline lastline+1,fileid
  317.          deleteline firstline-1,fileid
  318.          call prestore_pos(save_pos)
  319.          call pset_mark( firstline-1,lastline-1,firstcol-sl,lastcol-sl,marktype(),fileid)
  320.       elseif style='R' then
  321.          if not pblock_reflow(0,spc,tempofid) then
  322.             call pblock_reflow(1,spc,tempofid)
  323.          endif
  324.          call prestore_pos(save_pos)
  325.       else
  326.          if flg then
  327.             lside=style;rside=style;tside=style;tlc=style;trc=style;blc=style;brc=style
  328.          else
  329.             if style='P' then lside='{*';rside='*}';tside='*';tlc='{*';trc='*}';blc='{*';brc='*}'
  330.             elseif style='A' then lside=';';rside=' ';tside='*';tlc=';';trc=' ';blc=';';brc=' '
  331.             elseif style='C' then lside='/*';rside='*/';tside='*';tlc='/*';trc='*/';blc='/*';brc='*/'
  332.             elseif style=1 then lside='│';rside='│';tside='─';tlc='┌';trc='┐';blc='└';brc='┘'
  333.             elseif style=2 then lside='║';rside='║';tside='═';tlc='╔';trc='╗';blc='╚';brc='╝'
  334.             elseif style=3 then lside='|';rside='|';tside='-';tlc='+';trc='+';blc='+';brc='+'
  335.             elseif style=4 then lside='█';rside='█';tside='▀';tlc='█';trc='█';blc='▀';brc='▀'
  336.             elseif style=5 then lside='│';rside='│';tside='═';tlc='╒';trc='╕';blc='╘';brc='╛'
  337.             elseif style=6 then lside='║';rside='║';tside='─';tlc='╓';trc='╖';blc='╙';brc='╜'
  338.             elseif style='S' then lside='.*';rside='**';tside='*';tlc='.*';trc='**';blc='.*';brc='**'
  339.             else   style='B';lside=' ';rside=' ';tside=' ';tlc=' ';trc=' ';blc=' ';brc=' '
  340.             endif
  341.          endif
  342.          sl=length(lside)
  343.          width=1+lastcol-firstcol   /* width of inside of box */
  344.          side=substr('',1,width,tside)
  345.          line = substr('',1,firstcol-1)||blc||side||brc
  346.          insertline line,lastline+1,fileid
  347.          insertline substr('',1,firstcol-1)||tlc||side||trc,firstline,fileid
  348.          for i=firstline+1 to lastline+1
  349.             getline line,i,fileid
  350.             replaceline substr(line,1,firstcol-1)||lside||substr(line,firstcol,width)||rside||substr(line,lastcol+1),i,fileid
  351.          endfor
  352.          call prestore_pos(save_pos)
  353.          call pset_mark(firstline+1,lastline+1,firstcol+sl,lastcol+sl,marktype(),fileid)
  354.       endif
  355.       flg=0
  356.    endfor
  357. compile endif
  358.  
  359. defc c,change=
  360.    universal lastchangeargs, default_search_options
  361. compile if SETSTAY='?'
  362.    universal stay
  363. compile endif
  364. compile if defined(HIGHLIGHT_COLOR)
  365.    universal search_len
  366. compile endif
  367.  
  368. compile if SETSTAY
  369.    call psave_pos(savepos)
  370. compile endif
  371.    /* Insert default_search_options just before supplied options (if any)    */
  372.    /* so the supplied options will take precedence.                          */
  373.    args=strip(arg(1),'L')  /* Delimiter = 1st char, ignoring leading spaces. */
  374.    user_options=''
  375.    if args<>'' then        /* If args blank, use lastchangeargs. */
  376.       if default_search_options='' then
  377.          lastchangeargs=args
  378.       else
  379.          delim=substr(args,1,1)
  380.          p=pos(delim,args,2)   /* find last delimiter of 2 or 3 */
  381.          if p then
  382. compile if defined(HIGHLIGHT_COLOR)
  383.             search_len=p-2
  384. compile endif
  385.             p=pos(delim,args,p+1)   /* find last delimiter of 2 or 3 */
  386.             if p>0 then
  387.                user_options=substr(args,p+1)
  388.                args=substr(args,1,p-1)
  389.             endif
  390.          else
  391.             sayerror NO_REP__MSG
  392.          endif
  393.          if marktype() then
  394.             all=''
  395.          else           -- No mark, so override if default is M.
  396.             all='A'
  397.          endif
  398.          lastchangeargs=args || delim || default_search_options || all || user_options
  399.       endif
  400.    endif
  401.    if verify(upcase(user_options),'M','M') then
  402.       call checkmark()
  403.       /* Put this line back in if you want the M choice to force */
  404.       /* the cursor to the start of the mark.                    */
  405. ;;;   call pbegin_mark()  /* mark specified - make sure at top of mark */
  406.    endif
  407.    'xcom c 'lastchangeargs
  408.  
  409. compile if SETSTAY='?'
  410.    if stay then
  411. compile endif
  412. compile if SETSTAY
  413.       call prestore_pos(savepos)
  414. compile endif
  415. compile if SETSTAY='?'
  416.    endif
  417. compile endif
  418.  
  419. defc cd=
  420.    rc=0
  421.    if arg(1)='' then
  422.       dir= directory()
  423.    else
  424.       dir= directory(arg(1))
  425.    endif
  426.    if not rc then
  427.       sayerror CUR_DIR_IS__MSG dir
  428.    endif
  429.  
  430. defc center=
  431.    call pcenter_mark()
  432.  
  433. defc chr=
  434.    parse arg i '=' .
  435. compile if EVERSION < 5
  436.    setcommand 'chr 'i'='chr(i)'',5,1
  437.    cursorcommand
  438. compile else
  439.    sayerror 'chr 'i'='chr(i)''
  440. compile endif
  441.  
  442. compile if EPM
  443. defc close=
  444.    call windowmessage(0,  getpminfo(EPMINFO_EDITCLIENT),
  445.                       41,                 -- WM_CLOSE
  446.                       0,
  447.                       0)
  448. compile endif
  449.  
  450. defc deleteautosavefile
  451. compile if EVERSION < '4.12'
  452.    universal autosave
  453.    if autosave then               -- Erase the tempfile if autosave is on.
  454. compile else
  455.    if .autosave then               -- Erase the tempfile if autosave is on.
  456. compile endif
  457.       TempName = MakeTempName()
  458.       getfileid tempid, TempName  -- (provided it's not in the ring.)
  459.       if tempid='' then call erasetemp(TempName); endif
  460.    endif
  461.  
  462. ;  This command is the same function that has been attached to
  463. ;  the key Alt-equal.  Moved here as a separate command to make key
  464. ;  binding more flexible.  And to allow execution without a key binding.
  465. ;  In EPM, no getkey() prompt.  Cancel at first error.
  466. defc dolines=
  467.    if marktype()='LINE' then
  468. compile if EVERSION < 5
  469.       sayerror EX_ALL_YN__MSG
  470.       loop
  471.          k=upcase(getkey())
  472.          if k=esc then return ''; endif
  473.          if k=NO_CHAR or k=YES_CHAR then leave endif
  474.       endloop
  475. compile else
  476.       k=substr('0000'YES_CHAR || NO_CHAR, winmessagebox('Dolines', EX_ALL__MSG, 16389) - 1, 1)  -- YESNOCANCEL + MOVEABLE
  477.       if not k then return ''; endif  -- 'Y'=Yes; 'N'=No; '0'=Cancel
  478. compile endif
  479.       if k='Y' then
  480.          getmark firstline,lastline,i,i,fileid
  481.          for i=firstline to lastline
  482.             getline line,i,fileid
  483.             line
  484.          endfor
  485.          sayerror 0
  486.          return ''
  487.       endif
  488. compile if EVERSION < 5
  489.       sayerror 0
  490. compile endif
  491.    endif
  492.    if .line then
  493.       getline line
  494.       line
  495.    endif
  496.  
  497. /* This DEFC EDIT eventually calls the built-in edit command, by calling      */
  498. /* loadfile(), but does additional processing for messy-desk windowing (moves */
  499. /* each file to its own window), and ends by calling select_edit_keys().      */
  500. ; Parse off each file individually.  Files can optionally be followed by one
  501. ; or more commands, each in quotes.  The first file that follows a host file
  502. ; must be separated by a comma, an option, or a (possibly null) command.
  503. ;
  504. ; EPM doesn't give error messages from XCOM EDIT, so we have to handle that for
  505. ; it.
  506. compile if EVERSION < 5   -- E3 & EOS2:  display multiple messages on a cleared
  507.   define SAYERR = 'say'   -- screen, since only most recent SAYERROR can be seen.
  508. compile else
  509.   define SAYERR = 'sayerror'  -- EPM:  Message box shows all SAYERRORs
  510. compile endif
  511.  
  512. compile if LINK_HOST_SUPPORT & (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL')
  513.  compile if not defined(MVS)
  514.     MVS = 0
  515.  compile endif
  516.  compile if not defined(E3MVS)
  517.     E3MVS = 0
  518.  compile endif
  519.  compile if not defined(HOST_LT_REQUIRED)
  520.     HOST_LT_REQUIRED = 0
  521.  compile endif
  522. compile endif
  523.  
  524. compile if not EPM
  525. defc e,ed,edit=
  526. compile else
  527. defc e,ed,edit,epm=
  528. compile endif
  529. universal default_edit_options
  530. compile if not EPM
  531.    universal messy
  532. compile endif
  533.   compile if (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL') & not SMALL
  534.    universal fto                -- Need this passed to loadfile...
  535.   compile endif
  536.  
  537.    rest=strip(arg(1))
  538.  
  539.    if rest='' then   /* 'edit' by itself goes to next file */
  540. compile if EVERSION < 5
  541.       call pnextfile()
  542.       call select_edit_keys()
  543. compile else
  544.       nextfile
  545. compile endif
  546.       return 0
  547.    endif
  548.  
  549.    options=default_edit_options
  550.    parse value '0 0' with files_loaded new_files_loaded new_files not_found bad_paths truncated access_denied invalid_drive error_reading error_opening first_file_loaded
  551. --  bad_paths     --> Non-existing path specified.
  552. --  truncated     --> File contained lines longer than 255 characters.
  553. --  access_denied --> If user tried to edit a subdirectory.
  554. --  invalid_drive --> No such drive letter
  555. --  error_reading --> Bad disk(ette).
  556. --  error_opening --> Path contained invalid name.
  557.  
  558.    do while rest<>''
  559.       rest=strip(rest,'L')
  560.       if substr(rest,1,1)=',' then rest=strip(substr(rest,2),'L'); endif
  561.       ch=substr(rest,1,1)
  562. compile if (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL') & not SMALL
  563.  compile if (MVS or E3MVS) and not HOST_LT_REQUIRED  -- (MVS filespecs can start with '.)
  564.   compile if EVERSION >= '5.50'      -- Now use "" to support spaces in filenames
  565.       if 0 then                         -- No-op
  566.   compile else
  567.       if ch='"' then                    -- Command
  568.   compile endif
  569.  compile else
  570.   compile if EVERSION >= '5.50'     -- Now use "" to support spaces in filenames
  571.       if ch="'" then                    -- Command
  572.   compile else
  573.       if ch='"' | ch="'" then           -- Command
  574.   compile endif
  575.  compile endif
  576. compile else
  577.  compile if EVERSION >= '5.50'     -- Now use "" to support spaces in filenames
  578.       if ch="'" then                    -- Command
  579.  compile else
  580.       if ch='"' | ch="'" then           -- Command
  581.  compile endif
  582. compile endif
  583.          parse value rest with (ch) cmd (ch) rest
  584.          do while substr(rest,1,1)=ch & pos(ch,rest,2)
  585.             parse value rest with (ch) p (ch) rest
  586.             cmd = cmd || ch || p
  587.          enddo
  588.          cmd
  589.       elseif ch='/' then       -- Option
  590.          parse value rest with opt rest
  591.          options=options upcase(opt)
  592.       else
  593.          files_loaded=files_loaded+1  -- Number of files we tried to load
  594. compile if EVERSION >= '5.50'     -- Now use "" to support spaces in filenames
  595.       if ch='"' then
  596.          p=pos('"',rest,2)
  597.          if p then
  598.             file = substr(rest, 1, p)
  599.             rest = substr(rest, p+1)
  600.          else
  601.             sayerror INVALID_FILENAME__MSG
  602.             return
  603.          endif
  604.       else
  605. compile endif
  606. compile if HOST_SUPPORT & not SMALL
  607.          p=length(rest)+1  -- If no delimiters, take to the end.
  608.          p1=pos(',',rest); if not p1 then p1=p; endif
  609.          p2=pos('/',rest); if not p2 then p2=p; endif
  610.          p3=pos('"',rest); if not p3 then p3=p; endif
  611.          p4=pos("'",rest); if not p4 then p4=p; endif
  612.   compile if HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL'
  613.     compile if MVS or E3MVS
  614.          p4=p     -- Can't use single quote for commands if allowing MVS files
  615.     compile endif
  616.          p5=pos('[',rest); if not p5 then p5=p; endif  -- Allow for [FTO]
  617.          p=min(p1,p2,p3,p4,p5)
  618.   compile else
  619.          p=min(p1,p2,p3,p4)
  620.   compile endif
  621.          file=substr(rest,1,p-1)
  622.          if VMfile(file,more) then        -- tricky - VMfile modifies file
  623.             if p=p1 then p=p+1; endif     -- Keep any except comma in string
  624.             rest=more substr(rest,p)
  625.          else
  626. compile endif
  627.             parse value rest with file rest2
  628.             if pos(',',file) then parse value rest with file ',' rest
  629.             else rest=rest2; endif
  630. compile if HOST_SUPPORT & not SMALL
  631.          endif
  632.   compile if HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL'
  633.          if substr(strip(rest,'L'),1,1)='[' then
  634.             parse value rest with '[' fto ']' rest
  635.          else
  636.             fto = ''                           --  reset for each file!
  637.          endif
  638.   compile endif
  639. compile endif
  640. compile if EVERSION >= '5.50'     -- Now use "" to support spaces in filenames
  641.       endif
  642. compile endif
  643.  
  644.          call parse_filename(file,.filename)
  645.  
  646. compile if USE_APPEND  -- Support for DOS 3.3's APPEND, thanks to Ken Kahn.
  647.          If not(verify(file,'\:','M')) then
  648.             if not exist(file) then
  649.                File = Append_Path(File)||File  -- LAM todo: fixup
  650.             Endif
  651.          Endif
  652. compile endif
  653.  
  654. compile if WANT_WINDOWS         -- Always 0 for EPM
  655.          if messy then                            -- messy-desk style?
  656.             .windowoverlap=1
  657.             if pos('H',options) then      -- hidden option used?
  658.                call loadfile(file,options)
  659.             else
  660.                if not verify(file,'?*','M') and   -- If no wildcards
  661.                   not pos('D',options)    -- and not /D,
  662.                then
  663.                   if verify(file,':\','M') then   -- get fully qualified file
  664.                      getfileid newfileid,file
  665.                   else
  666.                      getfileid newfileid,directory()'\'file -- (add path if necessary).
  667.                      if newfileid='' then getfileid newfileid,file; endif
  668.                   endif
  669.                   if newfileid<>'' then           -- If it's already loaded,
  670.                      .box=1
  671.                      if newfileid.windowid=0 then   -- (in the hidden ring?)
  672.                         newwindow 'e /w' options file -- (Yes, have to edit it.)
  673.                      else
  674.                         activatefile newfileid       -- then just activate it.
  675.                      endif
  676.                      iterate
  677.                   endif
  678.                endif
  679.                newwindow 'e /w /n'  /* start a new file */
  680.                /* Newwindow 'e' creates an empty file just like E startup. */
  681.                getfileid emptyfileid
  682.                if not (rc and rc<>-282) then  -- sayerror('New file')
  683.                   if pos('Q',options) then sayerror 1; endif
  684.                   call loadfile(file,options argsep||'w')
  685.                   loadrc=rc
  686.                   getfileid newfileid
  687.                   if loadrc=-270 & newfileid=emptyfileid then  -- sayerror('Not enough memory')
  688.                      deletewindow
  689.                      stop
  690.                   endif           -- Otherwise, wildcard & some were loaded.
  691.                   call create_window_for_each_file(emptyfileid)
  692.                   .windowoverlap=1
  693.                   if not loadrc or loadrc=-282 or    -- sayerror('New file')
  694.                                    loadrc=-270 or    -- sayerror('Not enough memory')
  695.                                    loadrc=-278 then  -- sayerror('Lines truncated')
  696.                      /* Normal results, normal cleanup:  discard empty file. */
  697.                      activatefile emptyfileid
  698.                      quitview
  699.                      activatefile newfileid
  700.                   else     /* Unexpected error! */
  701.                      deletewindow
  702.                   endif
  703.                endif
  704.                prevwindow; .box=1; nextwindow
  705.             endif
  706.          else      -- not messy
  707. compile endif
  708.             call loadfile(file,options)
  709. compile if WANT_WINDOWS
  710.             prevfile;.box=1;nextfile
  711.          endif -- if messy
  712. compile endif
  713.  
  714.          if rc=-3 then        -- sayerror('Path not found')
  715.             bad_paths=bad_paths', 'file
  716.          elseif rc=-2 then    -- sayerror('File not found')
  717.             not_found=not_found', 'file
  718.          elseif rc=-282 then  -- sayerror('New file')
  719.             new_files=new_files', 'file
  720.             new_files_loaded=new_files_loaded+1
  721.          elseif rc=-278 then  --sayerror('Lines truncated')
  722.             truncated=truncated', 'file
  723.             .modify = 0
  724.          elseif rc=-5 then  -- sayerror('Access denied')
  725.             access_denied=access_denied', 'file
  726.          elseif rc=-15 then  -- sayerror('Invalid drive')
  727.             invalid_drive=invalid_drive', 'file
  728.          elseif rc=-286 then  -- sayerror('Error reading file')
  729.             error_reading=error_reading', 'file
  730.          elseif rc=-284 then  -- sayerror('Error opening file')
  731.             error_opening=error_opening', 'file
  732.          endif
  733.          if first_file_loaded='' then
  734.             if rc<>-3   &  -- sayerror('Path not found')
  735.                rc<>-2   &  -- sayerror('File not found')
  736.                rc<>-5   &  -- sayerror('Access denied')
  737.                rc<>-15     -- sayerror('Invalid drive')
  738.             then
  739.                getfileid first_file_loaded
  740.             endif
  741.          endif
  742.       endif  -- not "cmd"
  743.    enddo  -- while rest<>''
  744.    if files_loaded>1 then  -- If only one file, leave E3's message
  745.       if new_files_loaded>1 then p='New files:'; else p='New file:'; endif
  746. compile if EVERSION < 5  -- EPM doesn't give messages; have to supply in all cases.
  747.       if new_files || bad_paths || not_found || truncated || access_denied || error_reading || error_opening || invalid_drive <>
  748.          invalid_drive || error_opening || error_reading || access_denied || truncated || not_found || bad_paths || new_files
  749.       then                                        -- More than one.
  750. compile else
  751.       multiple_errors = (new_files || bad_paths || not_found || truncated || access_denied || error_reading || error_opening || invalid_drive <>
  752.                         invalid_drive || error_opening || error_reading || access_denied || truncated || not_found || bad_paths || new_files ) &
  753.                   '' <> new_files || bad_paths || not_found || truncated || access_denied || error_reading || error_opening || invalid_drive
  754.  
  755. compile endif
  756.          if new_files then $SAYERR NEW_FILE__MSG substr(new_files,2); endif
  757.          if not_found then $SAYERR FILE_NOT_FOUND__MSG':' substr(not_found,2); endif
  758. compile if EPM  -- If only one file, don't need "New file" msg in EPM.
  759.    else
  760.       multiple_errors = 0
  761.    endif
  762. compile endif
  763.          if bad_paths then $SAYERR BAD_PATH__MSG':' substr(bad_paths,2); endif
  764.          if truncated then $SAYERR LINES_TRUNCATED__MSG':' substr(truncated,2); endif
  765.          if access_denied then $SAYERR ACCESS_DENIED__MSG':' substr(access_denied,2); endif
  766.          if invalid_drive then $SAYERR INVALID_DRIVE__MSG':' substr(invalid_drive,2); endif
  767.          if error_reading then $SAYERR ERROR_OPENING__MSG':' substr(error_reading,2); endif
  768.          if error_opening then $SAYERR ERROR_READING__MSG':' substr(error_opening,2); endif
  769. compile if EVERSION < 5
  770.          pause
  771.       elseif new_files then sayerror NEW_FILE__MSG':' substr(new_files,2)
  772.       elseif bad_paths then sayerror BAD_PATH__MSG':' substr(bad_paths,2)
  773.       elseif not_found then sayerror FILE_NOT_FOUND__MSG':' substr(not_found,2)
  774.       elseif truncated then sayerror LINES_TRUNCATED__MSG':' substr(truncated,2)
  775.       elseif access_denied then sayerror ACCESS_DENIED__MSG':' substr(access_denied,2)
  776.       elseif invalid_drive then sayerror INVALID_DRIVE__MSG':' substr(invalid_drive,2)
  777.       elseif error_reading then sayerror ERROR_OPENING__MSG':' substr(error_reading,2)
  778.       elseif error_opening then sayerror ERROR_READING__MSG':' substr(error_opening,2)
  779.       endif
  780. compile else
  781.       if multiple_errors then
  782.          messageNwait(MULTIPLE_ERRORS__MSG)
  783.       endif
  784. compile endif
  785.       if first_file_loaded<>'' then activatefile first_file_loaded; endif
  786. compile if EVERSION < 5
  787.    endif
  788. compile endif
  789.  
  790. compile if not EPM
  791.    /* Save the edit RC through select_edit_keys, since it might get reset  */
  792.    /* by some command like 'tabs' or 'margins'.  This used to be in        */
  793.    /* select_edit_keys, but that made configurability hard.                */
  794.    saverc=rc
  795.    call select_edit_keys()
  796.    rc=saverc
  797.    .box=2
  798. compile elseif MENU_LIMIT
  799. ;compile if SHOW_MODIFY_METHOD = 'TITLE'
  800. ;  call settitletext(.filename) /* done internally */
  801. ;compile endif
  802.    if .visible & files_loaded then
  803.       call updateringmenu()
  804.    endif
  805. compile endif
  806.  
  807.  
  808. ; LAM - Edit a file along the EPATH.  This command will be included if
  809. ; the user is including the required routines.  If you've done a
  810. ;   SET EPMPATH=d:\EPM;d:\my_emacs;d:\E_macros
  811. ; and then do
  812. ;   ep stdcmds.e
  813. ; that will load this file, just as if you had entered
  814. ;   e d:\e_macros\stdcmds.e
  815. compile if USE_APPEND or (WANT_SEARCH_PATH and WANT_GET_ENV and not SMALL)
  816. defc ep, epath=
  817.    parse arg filename pathname .
  818.    if pathname='' then
  819. compile if E3
  820.       if filetype(filename)='BAT' then
  821. compile else
  822.       if filetype(filename)='CMD' then
  823. compile endif
  824.          pathname='PATH'
  825.       else
  826.          pathname=EPATH
  827.       endif
  828.    endif
  829.    if not exist(filename) then
  830.       filename = search_path_ptr(Get_Env(pathname,1),filename)filename
  831.    endif
  832.    'e 'filename
  833.  
  834.  compile if EPM
  835. defc op, opath, openpath=
  836.    "open 'ep "arg(1)"'"
  837.  compile endif
  838. compile endif
  839.  
  840.  
  841. ; jbl 1/12/89:  The syntax of ECHO is revised to be like browse().  It's
  842. ; a function so a macro can test its current value.
  843. defc echo =
  844. compile if EVERSION >= '4.12'
  845.    uparg=upcase(arg(1))
  846.    if uparg=ON__MSG or uparg=1 then
  847.       call echo(1)
  848.    elseif uparg=OFF__MSG or uparg='0' then
  849.       call echo(0)
  850.    else
  851.  compile if EVERSION < 5
  852.       if echo() then onoff = ON__MSG; else onoff = OFF__MSG; endif
  853.       cursor_command
  854.       setcommand 'echo' onoff,8,1
  855.  compile else
  856.       sayerror ECHO_IS__MSG word(OFF__MSG ON__MSG, echo()+1)
  857.  compile endif
  858.    endif
  859. compile else                         -- The old way, for E3 & EOS2FAM.
  860.    if arg(1) = '' then
  861.       echo 'ON'
  862.    else
  863.       echo arg(1)
  864.    endif
  865. compile endif
  866.  
  867. compile if TOGGLE_ESCAPE
  868. defc ESCAPEKEY
  869.    universal ESCAPE_KEY
  870.    uparg=upcase(arg(1))
  871.    if uparg=ON__MSG or uparg=1 then
  872.       ESCAPE_KEY = 1
  873.    elseif uparg=OFF__MSG or uparg=0 then
  874.       ESCAPE_KEY = 0
  875.    else
  876.       sayerror 'EscapeKey' word(OFF__MSG ON__MSG, ESCAPE_KEY+1)
  877.    endif
  878. compile endif
  879.  
  880.  
  881. define TEMPFILENAME = 'vTEMP_FILENAME'
  882. compile if WANT_ET_COMMAND     -- Ver. 3.09 - Let user omit ET command.
  883.  compile if EVERSION < 5
  884. defc et=
  885.  compile else
  886.  define TEMPFILENAME = 'tempfile'
  887. defc et,etpm=
  888.  compile endif
  889.    universal vTEMP_PATH,vTEMP_FILENAME
  890.    infile=arg(1); if infile='' then infile=MAINFILE endif
  891.    sayerror COMPILING__MSG infile
  892.  compile if EVERSION < 5
  893.    quietshell 'xcom et /e' vTEMP_FILENAME infile
  894.    if rc=-2 then sayerror CANT_FIND_PROG__MSG 'ET.Exe';stop endif
  895.  compile else
  896.    tempfile=vTEMP_PATH'ETPM'substr(ltoa(gethwnd(EPMINFO_EDITCLIENT),16),1,4)'.TMP'
  897.    -- quietshell 'xcom etpm /e 'tempfile infile
  898.    quietshell 'xcom etpm 'infile ' /e 'tempfile ' /p'upcase(EPATH)
  899.    if rc=-2 then sayerror CANT_FIND_PROG__MSG 'ETPM.EXE'; stop; endif
  900.    if rc=41 then sayerror 'ETPM.EXE' CANT_OPEN_TEMP__MSG '"'tempfile'"'; stop; endif
  901.  compile endif
  902.    if rc then
  903.       saverc = rc
  904.       call ec_position_on_error($TEMPFILENAME)
  905.       rc = saverc
  906.    else
  907.  compile if EPM
  908.       refresh
  909.  compile endif
  910.       sayerror COMP_COMPLETED__MSG
  911.    endif
  912.    call erasetemp($TEMPFILENAME) -- 4.11:  added to erase the temp file.
  913. compile endif
  914.  
  915.                -- No EXIT command in EPM.  Do it from the system pull-downs.
  916. compile if EVERSION < 5
  917. ;  Ver. 3.11D  Optional return code as argument.  Added by Davis Foulger
  918. defc exit=
  919.    if askyesno(EXIT_PROMPT__MSG) = YES_CHAR then
  920.       exit arg(1)
  921.    endif
  922.    sayerror 0
  923. compile endif
  924.  
  925.  
  926. defc expand=
  927.    universal expand_on
  928.    uparg=upcase(arg(1))
  929.    if uparg=ON__MSG then
  930.       expand_on = 1
  931.       call select_edit_keys()
  932.    elseif uparg=OFF__MSG then
  933.       expand_on = 0
  934.       call select_edit_keys()
  935.    elseif uparg='' then
  936. compile if EVERSION < 5
  937.       if expand_on then onoff = ON__MSG; else onoff = OFF__MSG; endif
  938.       cursor_command
  939.       setcommand 'expand' onoff,8,1
  940. compile else
  941.       sayerror 'EXPAND:' word(OFF__MSG ON__MSG, expand_on+1)
  942. compile endif
  943.    else
  944.       sayerror INVALID_ARG__MSG ON_OFF__MSG')'
  945.       stop
  946.    endif
  947.  
  948. defc f,file=
  949.    's 'arg(1)
  950.    if not rc then
  951.       .modify=0            -- If saved to a different file, turn modify off
  952.       'q'
  953.       call select_edit_keys()
  954.    endif
  955.  
  956.  
  957. ;  EPM's replacement for Alt-F.  "FILL <character>".
  958. defc fill=
  959.    call checkmark()
  960.    call pfill_mark(arg(1))
  961.  
  962.  
  963. compile if EVERSION < 4       -- With linking, GET can be an external module.
  964. defc get=
  965.    universal default_edit_options
  966.    get_file = strip(arg(1))
  967.    if get_file='' then sayerror NO_FILENAME__MSG 'GET'; stop endif
  968.    if pos(argsep,get_file) then
  969.       sayerror INVALID_OPTION__MSG
  970.       stop
  971.    endif
  972.    call parse_filename(get_file,.filename)
  973.    getfileid fileid
  974.    s_last=.last
  975.    'e /q /h /d' default_edit_options get_file
  976.    editrc=rc
  977.    getfileid gfileid
  978.    if editrc= -2 | .last=0 then  -- -2 = sayerror('New file')
  979.       'q'
  980.       if editrc=-2 then
  981.          sayerror FILE_NOT_FOUND__MSG':  'get_file
  982.       else
  983.          sayerror FILE_IS_EMPTY__MSG':  'get_file
  984.       endif
  985.       stop
  986.    endif
  987.    if editrc & editrc<> -278 then  -- -278 = sayerror('Lines truncated')
  988.       sayerror editrc
  989.       stop
  990.    endif
  991.    call psave_mark(save_mark)
  992.    top
  993.    mark_line
  994.    bottom
  995.    mark_line
  996.    activatefile fileid
  997.    rc=0
  998.    copy_mark
  999.    copy_rc=rc           -- Test for memory too full for copy_mark.
  1000.    activatefile gfileid
  1001.    'q'
  1002.    parse value save_mark with s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt
  1003.    if fileid=s_mkfileid then           -- May have to move the mark.
  1004.       diff=fileid.last-s_last          -- (Adjustment for difference in size)
  1005.       if fileid.line<s_firstline then s_firstline=s_firstline+diff; endif
  1006.       if fileid.line<s_lastline then s_lastline=s_lastline+diff; endif
  1007.    endif
  1008.    call prestore_mark(s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt)
  1009.    if copy_rc then
  1010.       sayerror NOT_2_COPIES__MSG get_file
  1011.    else
  1012.       call message(1)
  1013.    endif
  1014.    activatefile fileid
  1015.    call select_edit_keys()
  1016. compile endif
  1017.  
  1018. /* Uses findfile statement to search EPATH for the helpfile.              */
  1019. /* Its syntax: findfile destfilename,searchfilename[,envpathvar][,['P']]  */
  1020. defc help=
  1021. compile if EVERSION < 5
  1022.    universal messy
  1023. compile endif
  1024.    helpfile = HELPFILENAME
  1025.  
  1026. compile if EVERSION > 4
  1027.    -- 4.02:  search EPATH/DPATH for the help file.  New 'D' option on findfile.
  1028.    findfile destfilename, helpfile, '','D'
  1029.    if rc then    /* If not there, search the HELP path. */
  1030.       findfile destfilename, helpfile, 'HELP'
  1031.    endif
  1032. compile else
  1033.    findfile destfilename, helpfile,EPATH
  1034. compile endif
  1035.    if rc then
  1036.       /* If all that fails, try the standard path. */
  1037.       findfile destfilename, helpfile, 'PATH'
  1038.       if rc then
  1039.          sayerror FILE_NOT_FOUND__MSG':' helpfile
  1040.          return ''
  1041.       endif
  1042.    endif
  1043. compile if EVERSION < 5
  1044.  compile if WANT_WINDOWS
  1045.    if messy then
  1046.       newwindow 'e /w 'destfilename  /* load one view only */
  1047.       call setzoomwindow(1,1,1,25,screenwidth())
  1048.       .windowoverlap=1
  1049.    else
  1050.  compile endif
  1051.       'e /w 'destfilename  /* load one view of help only */
  1052.  compile if WANT_WINDOWS
  1053.    endif
  1054.  compile endif
  1055. compile else
  1056.    'openhelp' destfilename
  1057. compile endif
  1058.  
  1059. ; In EPM we don't do a getkey() to ask you for the key.  You must supply it
  1060. ; as part of the command, as in "key 80 =".
  1061. defc key=
  1062.    parse value arg(1) with number k .
  1063.    if not isnum(number) then sayerror INVALID_NUMBER__MSG;stop endif
  1064.    -- jbl:  Allow the user to specify the key in the command, so he can
  1065.    -- say "key 80 =" and avoid the prompt.
  1066.    if k == '' then
  1067. compile if EVERSION < 5
  1068.       k=mgetkey(KEY_PROMPT1__MSG)  -- Accept key from macro.
  1069.    endif
  1070.    if k<>esc then
  1071.       cursor_data
  1072. compile else
  1073.       sayerror KEY_PROMPT2__MSG '"key 'number' =", "key 'number' S+F3".'
  1074.       return
  1075.    else
  1076.       k=resolve_key(k)
  1077. compile endif
  1078.       for i=1 to number
  1079.          executekey k
  1080.       endfor
  1081. compile if EVERSION < 5
  1082.       cursor_command
  1083. compile endif
  1084.    endif
  1085.    sayerror 0
  1086.  
  1087.  
  1088. defc l, locate =  /* Note:  this DEFC also gets executed by the slash ('/') command. */
  1089.    universal default_search_options
  1090. compile if defined(HIGHLIGHT_COLOR)
  1091.    universal search_len
  1092. compile endif
  1093. compile if EVERSION < 5
  1094.    r=rc /* This little trick tells us whether we're in a macro or on command */
  1095.         /* line, so we'll know where to leave the cursor at end.             */
  1096. compile endif
  1097.    /* Insert default_search_options just before supplied options (if any)    */
  1098.    /* so the supplied options will take precedence.                          */
  1099.    args=strip(arg(1),'L')
  1100. compile if not defined(HIGHLIGHT_COLOR)
  1101.    if default_search_options<>'' then
  1102. compile endif
  1103.       delim=substr(args,1,1)
  1104.       p=pos(delim,args,2)
  1105.       user_options=''
  1106.       if p then
  1107.          user_options=substr(args,p+1)
  1108.          args=substr(args,1,p-1)
  1109.       endif
  1110.       if marktype() then
  1111.          all=''
  1112.       else           -- No mark, so override if default is M.
  1113.          all='A'
  1114.       endif
  1115. compile if defined(HIGHLIGHT_COLOR)
  1116.       search_len=length(args)-1   /***** added for hilite *****/
  1117. compile endif
  1118.       args=args|| delim || default_search_options || all || user_options
  1119. compile if not defined(HIGHLIGHT_COLOR)
  1120.    endif
  1121. compile endif
  1122.    'xcom l 'args
  1123. compile if EVERSION < 5
  1124.    if not rc and r then
  1125.       cursor_data
  1126.  compile if defined(HIGHLIGHT_COLOR)
  1127.       refresh
  1128.       sayat '', .windowy+.cursory-1,.windowx+.cursorx-1,
  1129.             HIGHLIGHT_COLOR, min(search_len, .windowwidth - .cursorx + 1)
  1130.       k = mgetkey(); executekey k
  1131.  compile endif
  1132.    else
  1133.       call leave_last_command(r,rc)
  1134.    endif
  1135. compile elseif defined(HIGHLIGHT_COLOR)
  1136.    if not rc then
  1137.  compile if EVERSION < '5.50'
  1138.       refresh
  1139.       sayat '', .cursory, .cursorx, HIGHLIGHT_COLOR, min(search_len, .windowwidth - .cursorx + 1)
  1140.  compile else
  1141.       circleit 1, .line, .col, .col+search_len-1, HIGHLIGHT_COLOR
  1142. ;     refresh
  1143.  compile endif
  1144.    endif
  1145. compile endif
  1146.  
  1147. ; As of EPM 5.18, this command supports use of the DOS or OS/2 ATTRIB command,
  1148. ; so non-IBM users can also use the LIST command.  Note that installing SUBDIR
  1149. ; (DOS) or FILEFIND (OS/2) is still preferred, since it's not necessary to
  1150. ; "clean up" their output.  Also, ATTRIB before DOS 3.? doesn't support the /S
  1151. ; option we need to search subdirectories.
  1152. defc list, findfile, filefind=
  1153.    universal vTEMP_FILENAME
  1154.    universal subdir_present
  1155.  compile if EVERSION < 5
  1156.    call save_command_state(cstate)
  1157.  compile endif
  1158.    /* If I say "list c:\util" I mean the whole util directory.  But we */
  1159.    /* have to tell SubDir that explicitly by appending "\*.*".         */
  1160.    spec = arg(1)
  1161.    call parse_filename(spec,.filename)
  1162.    if spec='' then    /* If no argument at all, assume current directory. */
  1163.       spec="*.*"
  1164.    elseif not verify(spec,'*?','M') then      /* If no wildcards... */
  1165. compile if EPM                                   /* assume directory.  */
  1166.       if pos(rightstr(spec,1),'\:') then         /* If ends in ':' or '\' */
  1167. compile else
  1168.       if pos(substr(spec,length(spec),1),'\:') then
  1169. compile endif
  1170.          spec=spec'*.*'                             /* just add '*.*'         */
  1171.       else
  1172.          spec=spec'\*.*'                            /* Otherwise, add '\*.*'  */
  1173.       endif
  1174.    endif
  1175.    src = subdir(spec' >'vTEMP_FILENAME)  -- Moved /Q option to defproc subdir
  1176.  
  1177.    'e' argsep'd' argsep'q' vTEMP_FILENAME
  1178.    call erasetemp(vTEMP_FILENAME)
  1179.    using_attrib=pos('ATTRIB.EXE',subdir_present)
  1180.    if .last then
  1181.       .filename='.DIR 'spec
  1182.       if using_attrib then            /* Handle differently          */
  1183.          getline line,1
  1184.          if src then                  /* Extract error message.      */
  1185.             'xcom q'
  1186. compile if EVERSION < 5
  1187.             call restore_command_state(cstate)
  1188. compile endif
  1189.             sayerror FILE_NOT_FOUND__MSG':  'line
  1190.          else                         /* Must delete the attributes.      */
  1191.             c=pos(':',line)           /* Delete through last space before */
  1192.             s=lastpos(' ',line,c+1)   /* the colon.  Can't use absolute   */
  1193.             if s then                 /* column position; changes with OS */
  1194.                call psave_mark(savemark)
  1195.                getfileid fid
  1196.                call pset_mark(1,.last,1,s,'BLOCK',fid)
  1197.                deletemark
  1198.                call prestore_mark(savemark)
  1199.             endif
  1200.          endif
  1201.       else
  1202.       endif
  1203.       .modify=0
  1204.    else
  1205.       'xcom q'
  1206. compile if EVERSION < 5
  1207.       call restore_command_state(cstate)
  1208. compile endif
  1209.       sayerror FILE_NOT_FOUND__MSG
  1210.    endif
  1211.    call select_edit_keys()
  1212.  
  1213. compile if WANT_LAN_SUPPORT
  1214. defc lock
  1215.    if arg(1)<>'' then
  1216.       'e 'arg(1)
  1217.       if rc & rc<>-282 then  --sayerror('New file')
  1218.          return 1
  1219.       endif
  1220.    endif
  1221.    call lock(.filename)
  1222. compile endif
  1223.  
  1224. compile if WANT_LONGNAMES='SWITCH'
  1225. defc longnames
  1226.    universal SHOW_LONGNAMES
  1227.    uparg=upcase(arg(1))
  1228.    if uparg=ON__MSG or uparg=1 then
  1229.       SHOW_LONGNAMES = 1
  1230.    elseif uparg=OFF__MSG or uparg=0 then
  1231.       SHOW_LONGNAMES = 0
  1232.    else
  1233.       sayerror LONGNAMES_IS__MSG word(OFF__MSG ON__MSG, SHOW_LONGNAMES+1)
  1234.    endif
  1235. compile endif
  1236.  
  1237. defc loopkey=
  1238.    parse value arg(1) with finish k .
  1239.    if upcase(finish)='ALL' then
  1240.       finish= .last-.line+1
  1241.    endif
  1242.    if not isnum(finish) then sayerror INVALID_NUMBER__MSG;stop endif
  1243.    if k == '' then
  1244. compile if EVERSION < 5
  1245.       k=mgetkey(KEY_PROMPT1__MSG)  -- Accept key from macro.
  1246.    endif
  1247.    if k<>esc then
  1248.       cursor_data
  1249. compile else
  1250.       sayerror KEY_PROMPT2__MSG '"loopkey 'finish' =", "loopkey 'finish' S+F3".'
  1251.    else
  1252.       k=resolve_key(k)
  1253. compile endif
  1254.       oldcol=.col
  1255.       for i=1 to finish
  1256.          executekey k;down;.col=oldcol
  1257.       endfor
  1258. compile if EVERSION < 5
  1259.       cursor_command
  1260. compile endif
  1261.    endif
  1262.    sayerror 0
  1263.  
  1264. defc lowercase=
  1265.    call plowercase()
  1266.  
  1267. compile if EPM
  1268. ;  In EOS2 you could query the margins by typing "margins" with no argument.
  1269. ;  It typed them into the command line.  In EPM we can't write to the command
  1270. ;  line (yet).  So the query uses a sayerror.
  1271. ;
  1272. defc margins,ma=
  1273.    if arg(1)<>'' then         -- if user gives an argument he's setting,
  1274.       'xcom margins' arg(1)   -- pass it to the old internal margins command.
  1275.    else
  1276.       'commandline margins' .margins   -- Note the new .margins field
  1277.    endif
  1278. compile endif
  1279.  
  1280. defc matchtab=
  1281.    universal matchtab_on
  1282.    uparg=upcase(arg(1))
  1283.    if uparg=ON__MSG then
  1284.       matchtab_on = 1
  1285.    elseif uparg=OFF__MSG then
  1286.       matchtab_on = 0
  1287.    elseif uparg='' then
  1288. compile if EVERSION < 5
  1289.       if matchtab_on then onoff = ON__MSG; else onoff = OFF__MSG; endif
  1290.       cursor_command
  1291.       setcommand 'matchtab' onoff, 10, 1
  1292. compile else
  1293.       sayerror 'MATCHTAB:' word(OFF__MSG ON__MSG, matchtab_on+1)
  1294. compile endif
  1295.    else
  1296.       sayerror INVALID_ARG__MSG ON_OFF__MSG')'
  1297.       stop
  1298.    endif
  1299.  
  1300. ; MultiCommand, or Many Commands - lets you enter many commands on a line,
  1301. ; like XEDIT's SET LINEND, but you specify the delimiter as part of the
  1302. ; command so there's never a conflict.  Example, using ';' as delimiter:
  1303. ;   mc ; top; c /begin/{/ *; top; c/end/}/ *; top
  1304. defc mc =
  1305.    parse value strip(arg(1),'L') with delim 2 rest
  1306.    do while rest <> ''
  1307.       parse value rest with cmd (delim) rest
  1308.       cmd
  1309.    enddo
  1310.  
  1311. defc n,name
  1312. compile if WANT_LONGNAMES='SWITCH'
  1313.    universal SHOW_LONGNAMES
  1314. compile endif
  1315.    -- Name with no args supplies current name.
  1316.    if arg(1)='' then
  1317. compile if EVERSION < 5
  1318.       setcommand 'Name '.filename,6
  1319. compile else
  1320.       'commandline Name '.filename
  1321. compile endif
  1322.    else
  1323. compile if WANT_LAN_SUPPORT | EVERSION >= '5.51'
  1324.       if .lockhandle then
  1325.          sayerror LOCKED__MSG
  1326.          return
  1327.       endif
  1328. compile endif
  1329. compile if SMARTFILE or EVERSION >= '5.50'
  1330.       oldname = .filename
  1331. compile endif
  1332.       call namefile(arg(1))
  1333. compile if SMARTFILE or EVERSION >= '5.50'
  1334.       if oldname <> .filename then .modify = .modify+1 endif
  1335. compile endif
  1336. compile if EVERSION > 5
  1337.       if get_EAT_ASCII_value('.LONGNAME')<>'' then
  1338.          call delete_ea('.LONGNAME')
  1339.  compile if WANT_LONGNAMES
  1340.   compile if WANT_LONGNAMES='SWITCH'
  1341.          if SHOW_LONGNAMES then
  1342.   compile endif
  1343.             .titletext = ''
  1344.   compile if WANT_LONGNAMES='SWITCH'
  1345.          endif
  1346.   compile endif
  1347.  compile endif
  1348.       endif  -- .LONGNAME EA exists
  1349.  compile if SHOW_MODIFY_METHOD = 'TITLE' | EVERSION < '5.50'
  1350.       call settitletext(.filename)
  1351.  compile endif
  1352.  compile if MENU_LIMIT
  1353.       call updateringmenu()
  1354.  compile endif
  1355. compile endif
  1356.       call select_edit_keys()
  1357.    endif
  1358.  
  1359. defc newwindow=
  1360. compile if EVERSION < 5
  1361.    universal messy
  1362.    if messy then opt=' /w'; else opt=''; endif
  1363.    rest=parse_file_n_opts(arg(1))
  1364.    newwindow 'e'opt rest
  1365.    call select_edit_keys()
  1366. compile else
  1367.    if .modify then
  1368.       'save'
  1369.       if rc then
  1370.          sayerror ERROR_SAVING_HALT__MSG
  1371.          return
  1372.       endif
  1373.    endif
  1374.    'open' .filename
  1375.    'quit'
  1376. compile endif
  1377.  
  1378. compile if EPM
  1379. ;  New in EPM.  Edits a file in a different PM window.  This means invoking
  1380. ;  a completely new instance of E.DLL, with its own window and data.  We do it
  1381. ;  by posting a message to the executive, the top-level E application.
  1382. defc o,open=
  1383.    fname=strip(arg(1))                    -- Remove excess spaces
  1384.    call parse_filename(fname,.filename)   -- Resolve '=', if any
  1385.  
  1386.    call windowmessage(0,  getpminfo(APP_HANDLE),
  1387.                       5386,                   -- EPM_EDIT_NEWFILE
  1388.                       put_in_buffer(fname),
  1389.                       1)                      -- Tell EPM to free the buffer.
  1390. compile endif
  1391.  
  1392. compile if EVERSION > 5
  1393. defc openhelp
  1394.  compile if 0
  1395.    rectangle = atol(4) || atol(75)  || atol(632) || atol(351)
  1396.  
  1397.    filename  = arg(1) \0
  1398.    exfile    = 'help.ex' \0
  1399.    topoffile = HELP_TOP__MSG\0
  1400.    botoffile = HELP_BOT__MSG\0
  1401.    rethwnd   = '1234'
  1402.    params =   atol(getpminfo(EPMINFO_HAB))          ||  /* application anchor block              */
  1403.               atol(getpminfo(EPMINFO_PARENTCLIENT)) ||  /* handle to parent of edit window       */
  1404.               atol(getpminfo(EPMINFO_OWNERCLIENT))  ||  /* handle to owner of edit window        */
  1405.               offset(rectangle)    ||  /* positioning of edit window            */
  1406.               selector(rectangle)  ||
  1407.               offset(filename)     ||  /* file to be edited                     */
  1408.               selector(filename)   ||
  1409.               atol(0)              ||  /* handle to editor pointer icon.        */
  1410.               atol(0)              ||  /* handle to mark pointer icon.          */
  1411.               atol(0)              ||  /* editor ICON.                          */
  1412.               atol(12)             ||  /* internal editor options               */
  1413.               atol(203)            ||  /* PM standard window styles (FCF_xxxx)  */
  1414.               atoi(1)              ||  /* TRUE = LARGE FONT,  FALSE = SMALL FONT*/
  1415.               offset(exfile)       ||  /* pre-compiled macro code file (EPM.EX) */
  1416.               selector(exfile)     ||
  1417.               offset(topoffile)    ||  /* top and bottom of file markers        */
  1418.               selector(topoffile)  ||
  1419.               offset(botoffile)    ||
  1420.               selector(botoffile)  ||
  1421.               atoi(0)              ||  /* unique window id specified for edit window */
  1422.               atol(0)              ||  /* environment variable to search for .ex */
  1423.               atoi(0)                  /* reserved for future use.              */
  1424.  
  1425.    call dynalinkc( E_DLL,
  1426.              '_EPM_EDITWINDOWCREATE',
  1427.               offset(params)      ||
  1428.               selector(params)    ||
  1429.               offset(rethwnd)     ||
  1430.               selector(rethwnd))
  1431.  compile else
  1432.  
  1433.    -- send EPM icon window a help message.  It will take care of
  1434.    -- the correct setting up of the help window.
  1435.    --
  1436.    call windowmessage(0,  getpminfo(APP_HANDLE),
  1437.                       5132,                   -- EPM_POPHELPBROWSER
  1438.                       put_in_buffer(arg(1)),
  1439.                       1)                      -- Tell EPM to free the buffer.
  1440.  compile endif
  1441. compile endif
  1442.  
  1443. ;  Print just the marked area, if there is one.  Defaults to printing on LPT1.
  1444. ;  Optional argument specifies printer.
  1445. defc print=  /* Save the users current file to the printer */
  1446.    parse arg prt ':'                             -- Optional printer name
  1447.    if not prt then prt=default_printer(); endif  -- Default
  1448.    prtnum = check_for_printer(prt)
  1449.    if prtnum then
  1450.       if not printer_ready(prtnum) then
  1451.          sayerror PRINTER_NOT_READY__MSG
  1452.          stop
  1453.       endif
  1454.    elseif substr(prt,1,2)<>'\\' then      -- Assume \\hostname\prt is correct.
  1455.       sayerror BAD_PRINT_ARG__MSG
  1456.       stop
  1457.    endif
  1458.    if marktype() then
  1459.       getmark firstline,lastline,firstcol,lastcol,markfileid
  1460.       getfileid fileid
  1461.       if fileid<>markfileid then
  1462.          sayerror OTHER_FILE_MARKED__MSG UNMARK_OR_EDIT__MSG markfileid.filename
  1463.          stop
  1464.       endif
  1465.       mt=marktype()
  1466.       'xcom e /n'             /*  Create a temporary no-name file. */
  1467.       if rc=-282 then  -- sayerror("New file")
  1468.          if marktype()='LINE' then deleteline endif
  1469.       elseif rc then
  1470.          stop
  1471.       endif
  1472.       getfileid tempofid
  1473.       call pcopy_mark()
  1474.       if rc then stop endif
  1475.       call pset_mark(firstline,lastline,firstcol,lastcol,mt,markfileid)
  1476.       activatefile tempofid
  1477.       sayerror PRINTING_MARK__MSG
  1478.    else
  1479.       sayerror PRINTING__MSG .filename
  1480.    endif
  1481. compile if EVERSION < '5.50'
  1482.    'xcom save /q' prt     /* This will not set .modify to 0 */
  1483. compile else
  1484.    'xcom save /ne /q' prt  /* /NE means No EOF (for Laserjet driver) */
  1485. compile endif
  1486.    if marktype() then .modify=0; 'xcom q' endif
  1487.    sayerror 0    /* clear 'printing' message */
  1488.  
  1489. compile if EVERSION > 5
  1490. defc processbreak
  1491.    universal Dictionary_loaded
  1492.    call showwindow('ON')             -- Make sure that the window is displayed.
  1493.    if dictionary_loaded then
  1494.       call drop_dictionary()
  1495.    endif
  1496.    sayerror MACRO_HALTED__MSG
  1497. compile endif
  1498.  
  1499. compile if WANT_PROFILE='SWITCH'
  1500. defc PROFILE
  1501.    universal REXX_PROFILE
  1502.    uparg=upcase(arg(1))
  1503.    if uparg=ON__MSG or uparg=1 then
  1504.       REXX_PROFILE = 1
  1505.    elseif uparg=OFF__MSG or uparg=0 then
  1506.       REXX_PROFILE = 0
  1507.    else
  1508.       sayerror 'Profile' word(OFF__MSG ON__MSG, REXX_PROFILE+1)
  1509.    endif
  1510. compile endif
  1511.  
  1512. compile if WANT_STACK_CMDS
  1513. definit
  1514.    universal mark_stack, position_stack
  1515.    mark_stack = ''
  1516.    position_stack = ''
  1517.  
  1518. defc popmark
  1519.    universal mark_stack
  1520.    parse value mark_stack with savemark '/' mark_stack
  1521.    call prestore_mark(savemark)
  1522.  
  1523. defc poppos
  1524.    universal position_stack
  1525.    parse value position_stack with fid saveposition '/' position_stack
  1526.    if fid='' then
  1527.       sayerror STACK_EMPTY__MSG
  1528.       return
  1529.    endif
  1530. compile if EPM  -- EPM has error checking; EOS2 & E3 just stop.
  1531.    display -2
  1532.    rc = 0
  1533. compile endif
  1534.    activatefile fid
  1535. compile if EPM
  1536.    display 2
  1537.    if rc then
  1538.       sayerror FILE_GONE__MSG
  1539.       return
  1540.    endif
  1541. compile endif
  1542.    call prestore_pos(saveposition)
  1543.  
  1544. defc pushmark
  1545.    universal mark_stack
  1546.    call checkmark()
  1547.    call psave_mark(savemark)  -- Note - this does an UNMARK
  1548.    call prestore_mark(savemark)
  1549.    if length(mark_stack) + length(savemark) >= MAXCOL then
  1550.       sayerror STACK_FULL__MSG
  1551.       return
  1552.    endif
  1553.    mark_stack = savemark'/'mark_stack
  1554.  
  1555. defc swapmark
  1556.    universal mark_stack
  1557.    call checkmark()
  1558.    call psave_mark(savemark)
  1559.    'popmark'
  1560.    if length(mark_stack) + length(savemark) >= MAXCOL then
  1561.       sayerror STACK_FULL__MSG
  1562.       return
  1563.    endif
  1564.    mark_stack = savemark'/'mark_stack
  1565.  
  1566. defc pushpos
  1567.    universal position_stack
  1568.    call psave_pos(saveposition)
  1569.    getfileid fid
  1570.    if length(position_stack) + length(saveposition fid) >= MAXCOL then
  1571.       sayerror STACK_FULL__MSG
  1572.       return
  1573.    endif
  1574.    position_stack = fid saveposition'/'position_stack
  1575.  
  1576. defc swappos
  1577.    universal position_stack
  1578.    call psave_pos(saveposition)
  1579.    getfileid fid
  1580.    'poppos'
  1581.    if length(position_stack) + length(saveposition fid) >= MAXCOL then
  1582.       sayerror STACK_FULL__MSG
  1583.       return
  1584.    endif
  1585.    position_stack = fid saveposition'/'position_stack
  1586. compile endif
  1587.  
  1588. defc qs,quietshell,quiet_shell=
  1589.    quietshell arg(1)
  1590.  
  1591. defc q,quit=
  1592.    -- Ver. 4.11c: If we're trying to quit the shell window, kill the process.
  1593. compile if EVERSION >= '4.11'
  1594.  compile if SHELL_USAGE
  1595.    if .filename = ".SHELL" then
  1596. ;     It's important to kill the process before we quit the window, else the
  1597. ;     process will churn merrily along without output.  If we're MAKEing a
  1598. ;     large C program and quit the editor, it can tie up the session.
  1599. ;     Simpler tasks like DIR and FILEFIND don't tie up the session.
  1600. ;
  1601. ;     Doesn't hurt anything if the process has already been killed.  The
  1602. ;     internal shell_kill function will merely beep at you.
  1603.       call shell_kill()
  1604.    endif
  1605.  compile endif
  1606. compile endif
  1607.  
  1608. compile if EVERSION > '5.19' & WANT_EPM_SHELL
  1609.    if leftstr(.filename, 15) = ".command_shell_" then
  1610.       'shell_kill'
  1611.       return
  1612.    endif
  1613. compile endif
  1614.  
  1615. compile if TRASH_TEMP_FILES
  1616.    if substr(.filename,1,1) = "." then      -- a temporary file
  1617.       .modify=0                             -- so no "Are you sure?"
  1618.    endif
  1619. compile endif
  1620.  
  1621.    getfileid quitfileid      -- Temp workaround
  1622. ;compile if EVERSION > 5
  1623. ;   if marktype() then
  1624. ;      getmark firstline,lastline,firstcol,lastcol,markfileid
  1625. ;      if markfileid = quitfileid then
  1626. ;         'ClearSharBuff'       -- Remove content of EPM shared text buffer
  1627. ;      endif
  1628. ;   endif
  1629. ;compile endif
  1630. compile if WANT_LAN_SUPPORT & EVERSION < '5.51'
  1631.    if .lockhandle then call unlock(quitfileid); endif
  1632. compile endif
  1633.    call quitfile()
  1634. compile if EVERSION < 5
  1635.    call select_edit_keys()
  1636.    .box=2
  1637. compile elseif MENU_LIMIT
  1638.    getfileid fileid
  1639.    if fileid <> quitfileid then    -- temp workaround - fileid not null if no more files;
  1640.                                    -- breaks updateringmenu.
  1641.    call updateringmenu()
  1642.    endif
  1643. compile endif
  1644.  
  1645. defc rc=
  1646.    arg(1)
  1647.    sayerror 'RC='rc''
  1648.  
  1649. defc reflow_all
  1650.    call psave_mark(savemark)
  1651.    call psave_pos(savepos)
  1652. compile if not EPM
  1653.    cursor_data
  1654. compile endif
  1655.    stopit = 0
  1656.    top
  1657.    do forever
  1658.       getline line
  1659.       do while line='' |                              -- Skip over blank lines or
  1660.                (lastpos(':',line)=1 & pos('.',line)=length(line)) |  -- lines containing only a GML tag or
  1661.                substr(line,1,1)='.'                                  -- SCRIPT commands
  1662.          if .line=.last then stopit=1; leave; endif
  1663.          down
  1664.          getline line
  1665.       enddo
  1666.       if stopit then leave; endif
  1667.       startline = .line
  1668.       unmark; mark_line
  1669.       call pfind_blank_line()
  1670.       if .line<>startline then
  1671.          up
  1672.       else
  1673.          bottom
  1674.       endif
  1675.       mark_line
  1676.       reflow
  1677.       getmark firstline,lastline
  1678.       if lastline=.last then leave; endif
  1679.       lastline+1
  1680.    enddo
  1681.    call prestore_mark(savemark)
  1682.    call prestore_pos(savepos)
  1683.  
  1684. defc s,save=
  1685.    universal save_with_tabs, default_save_options
  1686.    name=arg(1)
  1687.    call parse_leading_options(name,options)
  1688.    options = default_save_options options
  1689. compile if EVERSION >= '5.21'
  1690.    save_as = 0
  1691.    if name='' | name=UNNAMED_FILE_NAME then
  1692. compile else
  1693.    if name='' then
  1694. compile endif
  1695.       name=.filename
  1696. compile if EVERSION >= '5.21'
  1697.       if .filename=UNNAMED_FILE_NAME then
  1698.          result = saveas_dlg(name, type)
  1699.          if result then return result; endif
  1700.          'name' name
  1701.          if not rc then
  1702.             name=.filename
  1703.             save_as = 1
  1704.          endif
  1705.       endif
  1706. compile endif
  1707.    else
  1708.       call parse_filename(name,.filename)
  1709.    endif
  1710. compile if WANT_LAN_SUPPORT & EVERSION < '5.51'
  1711.    locked = .lockhandle
  1712.    if locked & not arg(1) then 'unlock'; endif
  1713. compile endif
  1714. compile if WANT_BOOKMARKS
  1715.    if .levelofattributesupport%8 - 2*(.levelofattributesupport%16) then
  1716.       'saveattributes'
  1717.    endif
  1718. compile endif
  1719. compile if not E3
  1720.    -- 4.10:  Saving with tab compression is built in now.  No need for
  1721.    -- the make-do proc savefilewithtabs().
  1722.    -- 4.10 new feature:  if save_with_tabs is true, always specify /t.
  1723.    if save_with_tabs then
  1724.       options = '/t' options
  1725.    endif
  1726. compile elseif WANT_TABS
  1727.    if isoption(options,'t') or save_with_tabs then
  1728.       src=savefilewithtabs(name,options)
  1729.    else
  1730. compile endif
  1731.       src=savefile(name,options)
  1732. compile if (EVERSION < '4.10') & WANT_TABS
  1733.    endif
  1734. compile endif
  1735.    if not src & not isoption(options,'q') then
  1736.       call message(SAVED_TO__MSG name)
  1737. compile if not E3
  1738.    elseif src=-5 then  -- call message('Access denied')
  1739.       if qfilemode(name, attrib) then      -- Error from DosQFileMode
  1740.          call message(src)    -- ? Don't know why got Access denied.
  1741.       else                    -- File exists:
  1742.          if attrib % 16 - 2 * (attrib % 32) then    -- x'10' is on
  1743.             call message(ACCESS_DENIED__MSG '-' IS_A_SUBDIR__MSG)  -- It's a subdirectory
  1744.          elseif attrib // 2 then                    -- x'01' is on
  1745.             call message(ACCESS_DENIED__MSG '-' READ_ONLY__MSG)    -- It's read/only
  1746.          elseif attrib % 4 - 2 * (attrib % 8) then  -- x'04' is on
  1747.             call message(ACCESS_DENIED__MSG '-' IS_SYSTEM__MSG)    -- It's a system file
  1748.          elseif attrib % 2 - 2 * (attrib % 4) then  -- x'02' is on
  1749.             call message(ACCESS_DENIED__MSG '-' IS_HIDDEN__MSG)    -- It's a hidden file
  1750.          else                                -- None of the above?
  1751.             call message(ACCESS_DENIED__MSG '-' MAYBE_LOCKED__MSG) -- Maybe someone locked it.
  1752.          endif
  1753.       endif
  1754.       rc = src  -- reset, since qfilemode() changed the RC.
  1755. compile endif
  1756.    elseif src<0 then          -- If RC > 0 assume from host save; and
  1757.       call message(src)       -- assume host routine gave error msg.
  1758.    endif
  1759. compile if EVERSION >= '5.21'
  1760.    if src & save_as then
  1761.       .filename=UNNAMED_FILE_NAME
  1762.  compile if SHOW_MODIFY_METHOD = 'TITLE'
  1763.       call settitletext(.filename)
  1764.  compile endif
  1765.  compile if MENU_LIMIT
  1766.       call updateringmenu()
  1767.  compile endif
  1768.    endif
  1769. compile endif
  1770. compile if E3 and SHOW_MODIFY_METHOD
  1771.    call show_modify()
  1772. compile endif
  1773. compile if WANT_LAN_SUPPORT & EVERSION < '5.51'
  1774.    if locked & not arg(1) then call lock(.filename); endif
  1775. compile endif
  1776.    return src
  1777.  
  1778. defc select_all =
  1779.    getfileid fid
  1780.    call pset_mark(1, .last, 1, length(textline(.last)), 'CHAR' , fid)
  1781.  
  1782. compile if SETSTAY='?'
  1783. defc stay=
  1784.    universal stay
  1785.    parse arg arg1; arg1=upcase(arg1)
  1786.  compile if EPM
  1787.    if arg1='' then sayerror 'Stay =' word(OFF__MSG ON__MSG, stay+1)
  1788.  compile else
  1789.    if arg1='' then sayerror 'Stay =' stay
  1790.  compile endif
  1791.    elseif arg1='1' | arg1=ON__MSG then stay=1
  1792.    elseif arg1='0' | arg1=OFF__MSG then stay=0
  1793.    else sayerror INVALID_ARG__MSG ON_OFF__MSG')'
  1794.    endif
  1795. compile endif
  1796.  
  1797. compile if EVERSION >= '4.11'
  1798. ; read a file from stdin
  1799. defc stdfile_read
  1800.  while  read_stdin() > 0 do
  1801.     join
  1802.     bottom
  1803.  endwhile
  1804.  
  1805. ; write a file to stdout
  1806. defc stdfile_write
  1807.  if .filename=='' then
  1808.     .filename='UNNAMED'
  1809.  endif
  1810.  's'
  1811.  'type '.filename
  1812.  'q'
  1813. compile endif
  1814.  
  1815. compile if EVERSION >= '5.50'  -- Earlier versions didn't retain trailing blanks anyway.
  1816. defc strip =
  1817.    do i=1 to .last
  1818.       getline line, i
  1819.       if length(line) & rightstr(line,1) == ' ' then
  1820.          replaceline strip(line, 'T'), i
  1821.       endif
  1822.    enddo
  1823. compile endif
  1824.  
  1825. compile if TOGGLE_TAB
  1826. defc TABKEY
  1827.    universal TAB_KEY
  1828.    uparg=upcase(arg(1))
  1829.    if uparg=ON__MSG or uparg=1 then
  1830.       TAB_KEY = 1
  1831.    elseif uparg=OFF__MSG or uparg=0 then
  1832.       TAB_KEY = 0
  1833.    else
  1834.       sayerror 'TabKey' word(OFF__MSG ON__MSG, TAB_KEY+1)
  1835.    endif
  1836. compile endif
  1837.  
  1838.  
  1839. compile if EVERSION >= 5
  1840. ;  In EOS2 you could query the tabs by typing "tabs" with no argument.
  1841. ;  It typed them into the command line.
  1842. ;
  1843. defc tabs=
  1844.    if arg(1)<>'' then         -- if user gives an argument to be set,
  1845.       'xcom tabs 'arg(1)      -- pass it to the old internal tabs command.
  1846.    else
  1847.       -- Note the new .tabs field; each file has its own tabs.
  1848.       'commandline Tabs' .tabs
  1849.    endif
  1850. compile endif
  1851.  
  1852.  
  1853. defc top=
  1854.    top
  1855.  
  1856. compile if WANT_LAN_SUPPORT
  1857. defc unlock
  1858.    parse arg file
  1859.    if file='' then
  1860.       getfileid fileid
  1861.    else
  1862.       getfileid fileid,file
  1863.       if fileid=='' then
  1864.          sayerror '"'file'"' DOES_NOT_EXIST__MSG
  1865.          return 1
  1866.       endif
  1867.    endif
  1868.    call unlock(fileid)
  1869. compile endif
  1870.  
  1871. defc uppercase=
  1872.    call puppercase()
  1873.  
  1874. compile if EPM
  1875. defc ver =
  1876.    sayerror EDITOR_VER__MSG ver(0)
  1877. compile endif
  1878.  
  1879. defc xcom_quit
  1880. compile if EVERSION < 5
  1881.    if .windowoverlap then
  1882.       quitview
  1883.    else
  1884.       'xcom q'
  1885.    endif
  1886. compile else
  1887.    'xcom q'
  1888. compile endif
  1889.  
  1890.