/****************************** Module Header ******************************* * * Module Name: put.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. * ****************************************************************************/ ; For linking version, PUT can be an external module. compile if not defined( SMALL) -- If compiled separately EA_comment 'This defines the PUT command; it can be linked, or executed directly.' define INCLUDING_FILE = 'PUT.E' include 'stdconst.e' include 'menuhelp.h' const tryinclude 'mycnf.e' const compile if not defined(NLS_LANGUAGE) NLS_LANGUAGE = 'ENGLISH' compile endif include NLS_LANGUAGE'.e' defmain -- External modules always start execution at DEFMAIN. 'Put' arg( 1) compile endif ; --------------------------------------------------------------------------- ;defc app, append, put -- now defined in STDCMDS.E (to execute put) defc Put universal last_append_file -- Put and append work the same, and the same as XEdit's PUT. -- If the file already exists, append to it. -- If no file is specified, use same file as last specified. -- If no mark, use append the entire file. name = arg( 1) call Parse_Leading_Options( name, options) if name = '' then app_file = last_append_file else app_file = Parse_File_N_Opts( name) last_append_file = app_file endif if app_file = '' then sayerror NO_FILENAME__MSG 'PUT' stop endif fis_console = (upcase( app_file) = 'CON' | upcase( app_file) = 'CON:') if fis_console then sayerror NO_CONSOLE__MSG return endif getfileid fileid if marktype() then fhad_mark = 1 call psave_mark( save_mark) call prestore_mark( save_mark) elseif .last = 0 then sayerror FILE_IS_EMPTY__MSG stop else fhad_mark = 0 call pset_mark( 1, .last, 1, 1, 'LINE', fileid) endif -- If file is already in memory, we'll leave it there for speed. parse value 1 Check_For_Printer( app_file) with falready_in_ring fis_printer . if fis_printer | fis_console then 'e /q /c' app_file -- Force creation of a new file else 'e /q /n' app_file -- Look for file already in ring if rc = -282 then -- -282 = sayerror("New file") falready_in_ring = 0 'q' 'e /q' app_file -- Not 'xcom e', so we can append to host files endif endif if fis_printer or fis_console or not falready_in_ring then if rc = -282 then deleteline elseif rc then stop endif endif getfileid tempofid if marktype() <> 'LINE' then insertline '', tempofid.last + 1 endif bottom call pCopy_Mark() copyrc = rc if copyrc then -- Check memory full, invalid path, etc. .modify = 0 'q' sayerror copyrc stop endif saverc = 0 -- If the app_file was already in memory, don't file it. if fis_printer or fis_console or not falready_in_ring then 'Save' options saverc = rc activatefile tempofid tempofid.modify = 0 'q' endif activatefile fileid if fhad_mark then call pRestore_Mark( save_mark) else unmark endif refresh call Repaint_Window()