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

  1. ;  For linking version, PUT can be an external module.
  2.  
  3. compile if not defined(SMALL)  -- If SMALL not defined, then being separately
  4.  define INCLUDING_FILE = 'PUT.E'
  5.    tryinclude 'MYCNF.E'        -- the user's configuration customizations.
  6.  
  7.  compile if not defined(SITE_CONFIG)
  8.     const SITE_CONFIG = 'SITECNF.E'
  9.  compile endif
  10.  compile if SITE_CONFIG
  11.     tryinclude SITE_CONFIG
  12.  compile endif
  13.  
  14.  compile if not defined(NLS_LANGUAGE)
  15.   const NLS_LANGUAGE = 'ENGLISH'
  16.  compile endif
  17. include NLS_LANGUAGE'.e'
  18. compile endif
  19.  
  20. defmain     -- External modules always start execution at DEFMAIN.
  21.    'put' arg(1)
  22.  
  23. defc app, append, put =
  24.    universal last_append_file
  25.  
  26.    -- Put and append work the same, and the same as XEdit's PUT.
  27.    -- If the file already exists, append to it.
  28.    -- If no file is specified, use same file as last specified.
  29.    -- If no mark, use append the entire file.
  30.    name = arg(1)
  31.    call parse_leading_options(name,options)
  32.    if name = '' then
  33.       app_file=last_append_file
  34.    else
  35.       app_file=parse_file_n_opts(name)
  36.       last_append_file=app_file
  37.    endif
  38.    if app_file='' then
  39.       sayerror NO_FILENAME__MSG 'PUT'
  40.       stop
  41.    endif
  42.    is_console = upcase(app_file)='CON' | upcase(app_file)='CON:'
  43. compile if EVERSION > 5
  44.    if is_console then
  45.       sayerror NO_CONSOLE__MSG
  46.       return
  47.    endif
  48. compile endif
  49.    getfileid fileid
  50.    if marktype() then
  51.       had_mark = 1
  52.       call psave_mark(save_mark)
  53.       call prestore_mark(save_mark)
  54.    elseif .last = 0 then sayerror FILE_IS_EMPTY__MSG; stop
  55.    else
  56.       had_mark = 0
  57.       call pset_mark(1,.last,1,1,'LINE',fileid)
  58.    endif
  59.    /* If file is already in memory, we'll leave it there for speed. */
  60.    parse value 1 check_for_printer(app_file) with already_in_ring is_printer .
  61.    if is_printer | is_console then
  62.       'e /q /c' app_file   /* force creation of a new file */
  63.    else
  64.       'e /q /n' app_file   /* look for file already in ring */
  65.       if rc=-282 then  -- -282 = sayerror("New file")
  66.          already_in_ring = 0
  67.          'q'
  68.          'e /q' app_file  /* not 'xcom e', so we can append to host files */
  69.       endif
  70.    endif
  71.    if is_printer or is_console or not already_in_ring then
  72.       if rc=-282 then
  73.          deleteline
  74.       elseif rc then
  75.          stop
  76.       endif
  77.    endif
  78.    getfileid tempofid
  79.    if marktype()<>'LINE' then
  80.       insertline '',tempofid.last+1
  81.    endif
  82.    bottom
  83.    copyrc=pcopy_mark()
  84.    if copyrc then /* Check memory full, invalid path, etc. */
  85.       .modify=0; 'q'
  86.       sayerror copyrc
  87.       stop
  88.    endif
  89.    error_saving=0
  90.    /* If the app_file was already in memory, don't file it. */
  91.    if is_printer or is_console or not already_in_ring then
  92. compile if EVERSION < 5
  93.       if is_console then pause; endif
  94. compile endif
  95.       'save' options
  96. compile if EVERSION < 5
  97.       if is_console then pause; endif
  98. compile endif
  99.       error_saving=rc
  100.       activatefile tempofid; tempofid.modify=0; 'q'
  101.    endif
  102.    activatefile fileid
  103.    if had_mark then
  104.       call prestore_mark(save_mark)
  105.    else
  106.       unmark
  107.    endif
  108. compile if EVERSION < 5
  109.    if not error_saving then
  110.       sayerror MARK_APPENDED__MSG app_file
  111.    endif
  112. compile else
  113.    refresh
  114.    -- call settitletext(.filename) /* done internally */
  115.    call repaint_window()
  116. compile endif
  117.