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