home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / SUBSET.E < prev    next >
Text File  |  1995-07-24  |  2KB  |  53 lines

  1. ; Subset.e - this presents you with a file containing the subset of the
  2. ; current file which contains a given string.  The argument to the Subset
  3. ; command is the argument to the Locate command, so that the desired options
  4. ; can be specified.  E.g.,
  5. ;    subset /officer/ c
  6. ;    subset -OS/2-
  7.  
  8. ; Author:  Larry Margolis
  9.  
  10. compile if not defined(SMALL)        -- If compiling stand-alone...
  11. include 'english.e'
  12.  
  13. defmain
  14.    'subset' arg(1)
  15. compile endif
  16.  
  17. defc subset =
  18.    getfileid startfid
  19.    'xcom e /c /q tempfile'
  20.    if rc<>-282 then  -- sayerror('New file')
  21.       sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
  22.       return
  23.    endif
  24.    getfileid subfid
  25.    .autosave = 0
  26.    browse_mode = browse()     -- query current state
  27.    if browse_mode then call browse(0); endif
  28.    activatefile startfid
  29.    call psave_pos(save_pos)
  30.    0
  31.    do forever
  32.       'xcom l' arg(1)
  33.       if rc then
  34.          leave
  35.       endif
  36.       insertline textline(.line), subfid.last+1, subfid
  37.       endline
  38.    enddo
  39.    call prestore_pos(save_pos)
  40.    activatefile subfid
  41.    if not .modify then
  42.       'xcom quit'
  43.       activatefile startfid
  44.       if browse_mode then call browse(1); endif  -- restore browse state
  45.       return
  46.    endif
  47.    sayerror 0   -- Delete last "not found" message.
  48.    deleteline 1
  49.    .modify = 0
  50.    if browse_mode then call browse(1); endif  -- restore browse state
  51.    .filename = '.subset'
  52.    .titletext = 'Subset of' startfid.filename 'matching:  'arg(1)
  53.