home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmmac.zip / STDCMDS.E < prev    next >
Text File  |  1996-04-19  |  78KB  |  2,342 lines

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