/****************************** Module Header ******************************* * * Module Name: revert.e * * Copyright (c) Netlabs EPM Distribution Project 2002 * * $Id$ * * =========================================================================== * * This file is part of the Netlabs EPM Distribution package and is free * software. You can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * Netlabs EPM Distribution. This library is distributed in the hope that it * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * ****************************************************************************/ ; Revert to saved - throw away changes and reload from disk ; The following command will throw away any changes made to a file since ; the last time it was loaded from disk, and reload the saved copy. It ; does nothing if the file doesn't exist on disk. ; by Larry Margolis compile if not defined( SMALL) -- If compiled separately define INCLUDING_FILE = 'REVERT.E' include 'stdconst.e' const tryinclude 'mycnf.e' const compile if not defined( NLS_LANGUAGE) NLS_LANGUAGE = 'ENGLISH' compile endif include NLS_LANGUAGE'.e' defmain 'Revert' compile endif ; --------------------------------------------------------------------------- ; Sets rc. Works with some virtual files. defc Revert rc = 0 fQuitUntitled = 0 fEnableLoadSelect = 0 do once = 1 to 1 getfileid startfid 'VSyncCursor' call pSave_Pos( SavedPos) if filesinring() = 1 then -- Load a new file to avoid window close fQuitUntitled = 1 'NewUntitledFile' getfileid untitledfid pActivatefile( startfid) endif compile if HOST_SUPPORT if not Exist( .filename) & not Check_For_Host_File( .filename) then compile else if not Exist( .filename) then compile endif if upcase( leftstr( .filename, 6)) = '.DOS ' then Cmd = substr( .filename, 6) Cmd 'PostMe QuitSameFile' 'PostMe RestorePos' SavedPos elseif upcase( leftstr( .filename, 5)) = '.TREE' then Cmd = substr( .filename, 2) Cmd -- 'PostMe QuitSameFile' -- The Tree cmds already do this 'PostMe RestorePos' SavedPos elseif upcase( leftstr( .filename, 11)) = '.NEPMD_INFO' then Cmd = 'NepmdInfo' Cmd 'PostMe QuitSameFile' else 'SayError '.filename 'does not exist on disk; nothing to revert to.' rc = sayerror( 'File not found') endif leave endif if .modify then rcx = WinMessageBox( 'Revert - reload file from disk', .filename' was modified.'\13 || 'Throw away changes to file on disk?', MB_OKCANCEL + MB_WARNING + MB_DEFBUTTON1 + MB_MOVEABLE) if rcx <> MBID_OK then rc = -293 -- sayerror( 'has been modified') leave endif endif .modify = 0 'DisableLoad' 'DisableSelect' fEnableLoadSelect = 1 if .lockhandle then 'UnLock' endif /* -- This is the old mode Mode = GetMode() if Mode = 'BIN' then Filename = .filename "o 'mc /be "EnquoteFileSpec( Filename)" /PostMe RestorePos "SavedPos"'" if rc = 0 then activatefile startfid .modify = 0 'quit' leave endif else */ 'e /d =' -- /d means load from disk even if in ring. if not rc then 'QuitSameFile' 'PostMe RestorePos 'SavedPos -- postme required endif /* endif */ enddo if fQuitUntitled then pActivateFile( untitledfid) getfileid fid if fid = untitledfid then 'xcom quit' pActivateFile( startfid) endif -- This is also required when 'xcom quit' is replaced by 'quit'. -- It doesn't seem to work here automatically, so execute it here -- again: 'RingSetFileNumber' endif if fEnableLoadSelect then 'EnableLoad' 'EnableSelect' endif