home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / REVERT.E < prev    next >
Text File  |  1992-09-01  |  1KB  |  46 lines

  1. ;   Revert to saved - throw away changes and reload from disk.
  2.  
  3. ; The following command will throw away any changes made to a file since
  4. ; the last time it was loaded from disk, and reload the saved copy.  It
  5. ; does nothing if the file doesn't exist on disk.
  6.  
  7. ;    by Larry Margolis
  8.  
  9. compile if not defined(HOST_SUPPORT)
  10.    tryinclude 'mycnf.e'
  11.  compile if not defined(HOST_SUPPORT)
  12.    const
  13.       HOST_SUPPORT = 'STD'
  14.  compile endif
  15.  
  16. defmain
  17.    'revert'
  18. compile endif
  19.  
  20. defc revert =
  21.  compile if HOST_SUPPORT
  22.    if not exist(.filename) & not check_for_host_file(.filename) then
  23.  compile else
  24.    if not exist(.filename) then
  25.  compile endif
  26.       sayerror .filename 'does not exist on disk; nothing to revert to.'
  27.       return sayerror("File not found")
  28.    endif
  29.    if .modify then
  30.       if askyesno('Throw away changes to' .filename'?')<>'Y' then
  31.          return -293  -- sayerror("has been modified")
  32.       endif
  33.    endif
  34.    getfileid startfid
  35.    'e /d ='            -- /D means load from disk even if in ring.
  36.    getfileid newfid    -- Remember the new fileid.
  37.    if rc = sayerror("new file") then  -- (Host) File not found
  38.       'quit'                        -- Don't throw away what we had.
  39.    elseif newfid<>startfid then     -- If we got something new...
  40.          activatefile startfid
  41.          .modify = 0
  42.          'quit'
  43.          activatefile newfid
  44.    endif
  45.  
  46.