home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmmac.zip / GET.E < prev    next >
Text File  |  1995-03-10  |  4KB  |  141 lines

  1. ;  For linking version, GET can be an external module.
  2.  
  3. compile if not defined(SMALL)  -- If SMALL not defined, then being separately compiled.
  4.  define INCLUDING_FILE = 'GET.E'
  5. const
  6.    tryinclude 'MYCNF.E'        -- the user's configuration customizations.
  7.  
  8.  compile if not defined(SITE_CONFIG)
  9.     const SITE_CONFIG = 'SITECNF.E'
  10.  compile endif
  11.  compile if SITE_CONFIG
  12.     tryinclude SITE_CONFIG
  13.  compile endif
  14.  
  15. const
  16.  compile if EVERSION >= 5
  17.   compile if not defined(WANT_BOOKMARKS)
  18.    WANT_BOOKMARKS = 'LINK'
  19.   compile endif
  20.  compile else
  21.    WANT_BOOKMARKS = 0
  22.  compile endif
  23.  compile if not defined(NLS_LANGUAGE)
  24.    NLS_LANGUAGE = 'ENGLISH'
  25.  compile endif
  26. include NLS_LANGUAGE'.e'
  27.  
  28. defmain     -- External modules always start execution at DEFMAIN.
  29.    'get' arg(1)
  30.  
  31.  compile if EVERSION >= 6
  32.    EA_comment 'This defines the GET command; it can be linked, or executed directly.'
  33.  compile endif
  34. compile endif  -- not defined(SMALL)
  35.  
  36. defc get=
  37.    universal default_edit_options
  38.    get_file = strip(arg(1))
  39.    if get_file='' then sayerror NO_FILENAME__MSG 'GET'; stop endif
  40.    if pos(argsep,get_file) then
  41.       sayerror INVALID_OPTION__MSG
  42.       stop
  43.    endif
  44.    call parse_filename(get_file,.filename)
  45.    getfileid fileid
  46.    s_last=.last
  47. compile if EVERSION < 5
  48.    'e /q /h /d' default_edit_options get_file
  49. compile else
  50.    display -1
  51.    'e /q /d' get_file
  52. compile endif
  53.    editrc=rc
  54.    getfileid gfileid
  55.    if editrc = -282 | not .last then   -- -282 = sayerror('New file')
  56.       'q'
  57. compile if EVERSION > 5
  58.       display 1
  59. compile endif
  60.       if editrc = -282 then
  61.          sayerror FILE_NOT_FOUND__MSG':  'get_file
  62.       else
  63.          sayerror FILE_IS_EMPTY__MSG':  'get_file
  64.       endif
  65.       stop
  66.    endif
  67.    if editrc & editrc<>-278 then  -- -278  sayerror('Lines truncated') then
  68. compile if EVERSION > 5
  69.       display 1
  70. compile endif
  71.       sayerror editrc
  72.       stop
  73.    endif
  74.    call psave_mark(save_mark)
  75. compile if WANT_BOOKMARKS
  76.    if not .levelofattributesupport then
  77.       'loadattributes'
  78.    endif
  79. compile endif
  80. compile if EVERSION > 5
  81.    get_file_attrib = .levelofattributesupport
  82. compile endif
  83.    top
  84.    mark_line
  85.    bottom
  86.    if rightstr(textline(.last), 1) = \26 then  -- Ends with EOF?
  87.       getline line
  88.       replaceline leftstr(line, length(line)-1)
  89.       .modify = 0
  90.    endif
  91.    mark_line
  92.    activatefile fileid
  93.    rc=0
  94.    copy_mark
  95.    copy_rc=rc           -- Test for memory too full for copy_mark.
  96.    activatefile gfileid
  97.    'q'
  98.    parse value save_mark with s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt
  99.    if fileid=s_mkfileid then           -- May have to move the mark.
  100.       diff=fileid.last-s_last          -- (Adjustment for difference in size)
  101.       if fileid.line<s_firstline then s_firstline=s_firstline+diff; endif
  102.       if fileid.line<s_lastline then s_lastline=s_lastline+diff; endif
  103.    endif
  104.    call prestore_mark(s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt)
  105.    activatefile fileid
  106. compile if EVERSION > 5
  107.    if get_file_attrib // 2 then
  108.       call attribute_on(1)  -- Colors flag
  109.    endif
  110.  compile if EVERSION >= 5.50  -- GPI has font support
  111.   compile if EVERSION >= '6.01b'
  112.    if get_file_attrib bitand 4 then
  113.   compile else
  114.    if get_file_attrib % 4 - 2 * (get_file_attrib % 8) then
  115.   compile endif
  116.       call attribute_on(4)  -- Mixed fonts flag
  117.    endif
  118.  compile endif
  119.   compile if EVERSION >= '6.01b'
  120.    if get_file_attrib bitand 8 then
  121.   compile else
  122.    if get_file_attrib % 8 - 2 * (get_file_attrib % 16) then
  123.   compile endif
  124.       call attribute_on(8)  -- "Save attributes" flag
  125.    endif
  126.    display 1
  127. compile endif
  128.    if copy_rc then
  129.       sayerror NOT_2_COPIES__MSG get_file
  130. compile if EVERSION < 5
  131.    else
  132.       call message(1)
  133. compile endif
  134.    endif
  135. compile if EVERSION < 5
  136.    call select_edit_keys()
  137. compile else
  138. ;  refresh
  139. ;  call repaint_window()
  140. compile endif
  141.