home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / WORDPROC.E < prev    next >
Text File  |  1996-02-09  |  2KB  |  70 lines

  1. ; This routine converts a file into a format suitable for input into a
  2. ; word processor.  It is assumed that the current file contains a number
  3. ; of paragraphs separated by blank lines.  Each paragraph is reflowed,
  4. ; and the line terminators are for each line but the last one in each
  5. ; paragraph gets changed so that the lines will be "glued" together
  6. ; when the file is saved, making each paragraph into one long line.
  7. ;                                  Larry Margolis
  8.  
  9. compile if EVERSION < '6.03'
  10.    *** Error:  This routine is only supported in EPM 6.03 or above.
  11. compile endif
  12.  
  13. compile if not defined(E_DLL)  -- Being separately compiled?
  14.    include 'stdconst.e'
  15.  
  16. defmain
  17.    'wordproc'
  18.  
  19. compile endif -- not defined(E_DLL)
  20.  
  21. #define MAXLNSIZE_UNTERMINATED 1
  22.  
  23. defc wordproc
  24.    getfileid fid
  25.    call psave_mark(savemark)
  26.    call psave_pos(savepos)
  27.    oldmargins = .margins
  28.    oldmodify = .modify
  29.    oldautosave = .autosave
  30.    .autosave = 0        -- Don't want to go crazy autosaving...
  31.    .margins = '2 72 1'  -- This should make it look nice...
  32.    stopit = 0
  33.    top
  34.    do forever
  35.       getline line
  36.       do while line=''                                -- Skip over blank lines
  37.          if .line=.last then stopit=1; leave; endif
  38.          down
  39.          getline line
  40.       enddo
  41.       if stopit then leave; endif
  42.       startline = .line      -- Startline is first line of paragraph
  43.       unmark; mark_line
  44.       call pfind_blank_line()
  45.       if .line<>startline then
  46.          up
  47.       else
  48.          bottom
  49.       endif
  50.       mark_line
  51.       reflow
  52.       getmark firstline, lastline    -- New first and last lines of marked region.
  53.       do i = firstline to lastline-1
  54.          call setterm(fid, i, MAXLNSIZE_UNTERMINATED)
  55.       enddo
  56.       if lastline=.last then leave; endif
  57.       lastline+1
  58.    enddo
  59.    .margins  = oldmargins
  60.    .modify   = oldmodify + 1
  61.    .autosave = oldautosave
  62.    call prestore_mark(savemark)
  63.    call prestore_pos(savepos)
  64.  
  65.  
  66. defproc setterm(fid, line, termtype)
  67.    return dynalink32(E_DLL,
  68.                     'EtkChangeLineTerminator',  -- Not exported until 1995/03/06
  69.                     gethwndc(EPMINFO_EDITCLIENT) || atol(fid) || atol(line) || atol(termtype))
  70.