Article 132382 of comp.os.vms:
Path: nntpd.lkg.dec.com!crl.dec.com!crl.dec.com!bloom-beacon.mit.edu!newsserver.pixel.kodak.com!news.sprintlink.net!newsfeed.internetmci.com!info.ucla.edu!ihnp4.ucsd.edu!mvb.saic.com!info-vax
From: "KADOW@USOPS.enet.dec.com dtn:297-5349, MR01-1/A65" <kadow@usops.ENET.dec.com>
Newsgroups: comp.os.vms
Subject: Utility to Edit Multiple Files in 1 Editor Session
Message-ID: <9510240026.AA02413@us1rmc.bb.dec.com>
Date: Mon, 23 Oct 95 20:34:16 EDT
Organization: Info-Vax<==>Comp.Os.Vms Gateway
X-Gateway-Source-Info: Mailing List
Lines: 296

Following in a command procedure utility I wrote awhile ago.
Extract it into EDIT_FILES.COM, then edit it to remove these
comments.

EDIT_FILES.COM will accept a number of files, merge them into
1 files, allow you to edit the 1 file and then break out the
1 file into the original file, it does a differences and only
replaces those who have changed.  In the first few lines you
can customize the editor and whether you want to be asked if
a modified file should be written.

This is yours to keep, if you have comments about the code or
functions please let me know, I want to improve it if I can.

-Paul

------------------------------ cut here ------------------------
$!------------------------------------------------------------------
$! Edit_files.com
$!
$!	This command procedure will ask for a file specification,
$!	or multiple file specifications.  It will then combine all 
$!	these files into one tmp file that the user may edit.  
$!	Then, after the edit session the individual files are 
$!	broken out, the user may be asked if the new modified 
$!	file(s) should replace the old file(s).
$!	
$!      When editing the combined file, do not change or delete
$!      the delimiter line between the files.
$!
$!	Written, Jan 1992, Paul Kadow
$!------------------------------------------------------------------
$
$!*********************************
$! customization area
$! This may also be done dynamicly
$!*********************************
$   editor = "editx/tpu"              !editor
$!  editor = "editx/edt"
$   confirm_replace_changed_file=1    !whether or not you want to be
$!   confirm_replace_changed_file=0    !asked when replacing a file
$!*****************************
$
$   gosub init
$   ws "Edit_files.com v3.0"
$   gosub get_list_of_files
$   close/nolog files_list
$   create edit_files_'pid'.tmp_edit                !tmp edit file
$   gosub merge_files_into_one                      !combine the files
$   If mcnt .eq. 0 then goto exit                   !no files selected
$   hold_file = F$sea("edit_files_''pid'.tmp_edit")
$   assign/user sys$command sys$input 
$   'editor edit_files_'pid'.tmp_edit               !edit the files
$   If hold_file .eqs. F$sea("edit_files_''pid'.tmp_edit") -  
       then goto exit                               !no changes
$   gosub break_out_files                           !break out and write files
$!*******
$ Exit:
$!*******
$   If F$sea("edit_files_''pid'.*;*") .nes. "" then -
       delex  edit_files_'pid'.*;*
$ Exit
$
$!***********************
$ merge_files_into_one:
$!***********************
$   close/nolog files_list
$   sort/nodupl edit_files_'pid'.file_list edit_files_'pid'.file_list
$   purgex edit_files_'pid'.file_list
$   mcnt=0
$   open/read files_list edit_files_'pid'.file_list
$ merge_loop:
$   read/end=merge_eof files_list file
$   mcnt=mcnt+1
$!   ws ""
$   ws "''bold'Now Merging:  ''File'''off' "
$!   ws "''bold'              (ignore warnings around incompatable file attributes)''off'"
$   close/nolog delimiter_file 
$   open/write  delimiter_file edit_files_'pid'.delim
$   file = F$elem(0,";",file)                       !remove version from file
$   write delimiter_file "''delim'''file')*****"    !write delimiter file
$   close/nolog delimiter_file 
$   convert/append edit_files_'pid'.delim,'file' edit_files_'pid'.tmp_edit 
$   delex  edit_files_'pid'.delim;*
$   goto merge_loop
$
$ merge_eof:
$   close/nolog files_list
$   delex edit_files_'pid'.file_list;*
$ return
$
$!***********************
$ break_out_files:             
$!***********************
$   cnt=0
$   close/nolog infile 
$   open/read infile edit_files_'pid'.tmp_edit
$ read_loop:
$   read/end=break_eof infile inrec
$   cnt=cnt+1
$   If F$ext(0,F$len(delim),inrec) .eqs. delim then gosub new_out_file
$   If F$ext(0,F$len(delim),inrec) .nes. delim then write outfile inrec
$   goto read_loop
$ break_eof:
$   gosub check_differences_and_write
$   close/nolog infile 
$ return
$
$!***********************
$ new_out_file:
$!***********************
$ If cnt .ne. 1 then gosub check_differences_and_write
$
$!->get ready to write to new file
$   file_name = F$elem(1,"(",inrec)           
$   file_name = F$elem(0,")",file_name)       
$   close/nolog outfile
$   open/write  outfile edit_files_'pid'.tmp_file
$ return
$
$!*****************************
$ check_differences_and_write:
$!*****************************
$   close/nolog outfile 
$   diff edit_files_'pid'.tmp_file 'file_name 
$
$   If $severity .eqs. 3                    !found differences
$   then
$       If  confirm_replace_changed_file    !user want to be asked?
$       then 
$            ws "Copy new modified file over old one ?"
$            Inquire ans/nopun  "    ('Y'es, 'N'o, 'Q'uit, 'R'eplace rest) "
$            If ans .eqs. "R" then confirm_replace_changed_file = 0
$            If ans .eqs. "R" then ans = "Y"
$            If ans .eqs. "Q" then goto exit
$            If ans .eqs. "Y" then copy edit_files_'pid'.tmp_file 'file_name
$            If ans .nes. "Y" then ws "''bold'File, ''file_name', NOT copied.''off'"
$       else 
$            copy edit_files_'pid'.tmp_file 'file_name
$       Endif
$   else 
$      ws "''bold'File, ''file_name', no modifications made.''off'"
$   Endif
$   delex edit_files_'pid'.tmp_file;*
$ return
$         
$!***********************
$ get_list_of_files:
$!***********************
$   close/nolog files_list
$   open/write  files_list edit_files_'pid'.file_list
$   fcnt = 0
$ files_loop1:
$   ws ""
$   inquire input_file "Files to edit (? help) "
$   If input_file .eqs. "^L" then gosub list_the_files
$   If input_file .eqs. "^C" then gosub customize
$   If input_file .eqs. "?"  then call  get_help
$   If F$ext(0,1,input_file) .eqs. "-" then gosub remove_file
$   If input_file .eqs. "^L" .or. -
       input_file .eqs. "^C" .or. -
       input_file .eqs. "?"  .or. -
       input_file .eqs. "-"  -
       then goto files_loop1
$   If "''input_file'" .eqs. "" then return
$   fcnt = fcnt + 1
$   prev_file = ""
$ files_loop2:
$   file = F$sea("''input_file'",'fcnt)             !get next file
$   If file .eqs. "" then goto files_loop1          !no more files
$   If file .eqs. prev_file then goto files_loop1 
$   prev_file = file
$   write files_list "''file'"
$   goto files_loop2
$   
$!***********************
$ remove_file:
$!***********************
$   close/nolog files_list
$   sort/nodupl edit_files_'pid'.file_list edit_files_'pid'.file_list
$   purgex edit_files_'pid'.file_list
$   open/read  infile  edit_files_'pid'.file_list 
$   open/write outfile edit_files_'pid'.file_list
$   input_file = input_file - "-"
$ remove_file_files_loop:
$   read/end=remove_eof infile inrec
$   If F$loc(input_file,inrec) .ne. F$len(inrec) then -
       goto remove_file_files_loop
$   write outfile "''inrec'"
$   goto remove_file_files_loop
$ remove_eof:
$   close/nolog infile
$   close/nolog outfile
$   close/nolog files_list
$   sort/nodupl edit_files_'pid'.file_list edit_files_'pid'.file_list
$   purgex edit_files_'pid'.file_list
$   open/append files_list edit_files_'pid'.file_list
$ return
$
$!***********************
$ list_the_files:
$!***********************
$   ws ""
$   close/nolog files_list
$   sort/nodupl edit_files_'pid'.file_list edit_files_'pid'.file_list
$   purgex edit_files_'pid'.file_list
$   open/read files_list edit_files_'pid'.file_list
$   lcnt=0
$ list_the_files_loop:
$   read/end=list_eof files_list rec
$   lcnt = lcnt + 1
$   If lcnt .gt. 20
$      then ws ""
$           inquire/nopun ans "Hit <CR> to continue . . ."
$           lcnt = 0
$   endif
$   ws "''rec'"
$   goto list_the_files_loop
$ list_eof:
$   close/nolog files_list
$   open/append files_list edit_files_'pid'.file_list
$ return
$
$!***********************
$ customize:
$!***********************
$   ws ""
$   save_editor = editor
$   ws "Please enter the editor you wish to use."
$   inquire editor "    Current editor is: (''EDITOR')"
$   If editor .eqs. "" then editor = save_editor
$   
$   ws ""
$   ws "You have the option of being asked whether or not"
$   ws "a modified file should written."
$   inquire ans "    Do you wish to be asked (Y/N)"
$   If F$ext(0,1,ans) .eqs. "Y"
$      then confirm_replace_changed_file=1    
$      else confirm_replace_changed_file=0
$   Endif
$ return
$
$!***********************
$ get_help: subroutine
$!***********************
$   type sys$input

You may enter:

   file.dat - ie:  LOGIN.COM
                   AR*.COM
                   CIC$COM:EB*.COM
                   *

    ^L    To list the files currently selected.

    ^C    To customize the editor and whether you wish
          to be asked if a modified file should be saved.

     ?    To get this message.

   -STR   This option will remove from your file list any 
          file name that contains the string STR. 

   <CR>   When you are done selecting and want to continue.

$ endsubroutine
$ return
$
$!***********************
$ init:
$!***********************
$   pid     = f$getjpi("","pid")
$   ws      = "write sys$output"
$   self    = F$envir("PROCEDURE")
$   self    = F$par(self,,,"NAME") + F$par(self,,,"TYPE")
$   delim   = "**`\~/`**--file_delimeter_line--**`\~/`**(" 
$
$   Escape[0,8] = 27
$   blink   = "''Escape'[5m"
$   bold    = "''Escape'[1m"
$   uline   = "''Escape'[4m"
$   off     = "''Escape'[0m"
$   home    = "''Escape'[f"
$   clear   = "''Escape'[2J"
$ return

------------------------------ cut here ------------------------

==-===-==-===-==-===-==-===-==-===-==-===-==-===-==-===-==-===-==-===-==
||  Paul M. Kadow                      kadow@usops.enet.dec.com       ||
||  MR01-1/A65, 200 Forest St.         Dtn:297-5349  (508) 467-5349   ||
||  Digital Equipment Corporation      System Manager                 ||
||  Marlboro MA 01752                  Global Processing Services     ||
||          Excuse me?  What does God need with a Star ship?          ||
==-===-==-===-==-===-==-===-==-===-==-===-==-===-==-===-==-===-==-===-==


