From: NL0242T@nlzcl.decnet.philips.nl (Oscar van Eijk)
Subject: Re: WANTED: Extracting utility for VMS_SHARE
Organization: Philips Communication & Processing Services
Date: Fri, 4 Sep 1992 09:28:12 GMT
X-News-Reader: VMS NEWS 1.23

Hi there,

> I was wondering if anyone would happen to have a utility that extracts VMS_SHARE
> files in the correct order.  This would be nice when there are over 30 or so 
> files to be extracted.  Thanks!!!

A while ago I wrote a quick dirty program that does something like that.
I named it UnArc.Com and you can find it below.

To use it, create a symbol for it, e.g. unarc :== "@<disk>:[<path>]unarc".
Extract all archives as <whatever>.01, <whatever>.02 ... <whatever>.nn
The following line has to be added in <whatever>.01, immedialty before the
'CUT HERE' line:
-+-+-+-+-+-+-+-+ START OF PART 1 -+-+-+-+-+-+-+-+
or at least the first 6 characters ('-+-+-+')

Then type :
   unarc [-o<output_file>] <whatever>.*
or
   unarc [-o<output_file>] <whatever>.01 <whatever>.02 ...
where <output_file> is a temporary name of the archive and a sub directory
that will be created. Default is UnArc.Com and UnArc.Dir.

The program works fine for me, I think I solved most of the problems I've
had with it. If anybody finds some bugs, let me know.
If anybode makes any changes to the program; please let me know as well.

Have fun with it!

Oscar.

!------------------------- Begin UnArc.Com -------------------------------------
$	set noverify
$	on error then $ goto error_occured
$	on severe_error then $ goto error_occured
$	on control_y then $ goto handler
$	ws :== "write sys$output"
$	goto get_output
$!
$!******************************************************************************
$!*                                                                            *
$!*  FILENAME:                                                                 *
$!*  =========                                                                 *
$!*     UnArc.Com                                                              *
$!*                                                                            *
$!*  DESCRIPTION:                                                              *
$!*  ============                                                              *
$!*     This file reads given filenames which are supposed to be VMS archive   *
$!*     files and stores them all in one file. This file will then run to      *
$!*     extract the archive.                                                   *
$!*                                                                            *
$!*  LOGICALS NEEDED:                                                          *
$!*  ================                                                          *
$!*     None                                                                   *
$!*                                                                            *
$!*  PARAMETERS NEEDED:                                                        *
$!*  ==================                                                        *
$!*     p1         Optional, output file name                                  *
$!*     p2         Required, input file name(s), wildcards allowed             *
$!*     p3,p4...   Optional, input file names, no wildcards allowed            *
$!*                                                                            *
$!*  FILES NEEDED:                                                             *
$!*  =============                                                             *
$!*     None                                                                   *
$!*                                                                            *
$!*  HISTORY:                                                                  *
$!*  ========                                                                  *
$!*     Version:    Date:             Author:                                  *
$!*     --------    -----             -------                                  *
$!*     1.0         20-07-92          Oscar van Eijk, CompuHelp                *
$!*                                                                            *
$!******************************************************************************


$!******************************************************************************
$!
$!==>	Read the first paramater from the command line and find out the name
$!	of the output_file to store in
$!
$ get_output:
$!
$	if p1 .eqs. "" .or. p1 .eqs. "-H" .or. (f$locate("?",p1) .lt. -
	   f$length(p1)) then $ goto give_help
$	if f$extract(0,2,p1) .eqs. "-O"
$	   then
$		if f$length(p1) .eq. 2
$		   then
$			output_file = "''p2'"
$			pcounter = 3
$		   else
$			output_file = "''f$extract(2,f$length(p1)-2,p1)'"
$			pcounter = 2
$		endif
$		if output_file .eqs. "" then $ goto give_help
$	   else
$		read/end=end/prompt="_Output file: " sys$command output_file
$		pcounter = 1
$	endif
$	if output_file .eqs ""
$	   then
$		ws "No output_file name, using UNARC.COM"
$		output_file = "unarc"
$	endif
$	if f$locate(".",output_file) .eq. f$length(output_file) then -
	   $ output_file = "''output_file'.com'"
$	goto get_input
$!
$!******************************************************************************


$!******************************************************************************
$!
$!==>	read the parameter(s) that contain the input_file names
$!
$ get_input:
$!
$	input_file = p'pcounter'
$	pcounter = pcounter + 1
$	file_counter = 1
$	if f$locate("*",input_file) .lt. f$length(input_file) then -
	    $ goto wildcard_used
$	input_file'file_counter' = input_file
$!
$ read_from_params:
$!
$	check_for_file = input_file'file_counter'
$	if f$search("''check_for_file'") .eqs. "" then $ goto file_not_found
$	file_counter = file_counter + 1
$	input_file'file_counter' = p'pcounter'
$	pcounter = pcounter + 1
$	if p'pcounter' .eqs. ""
$	   then
$		number_of_files = file_counter
$		goto start_run
$	endif
$	goto read_from_params
$!
$!******************************************************************************


$!******************************************************************************
$!
$!==>	All filenames are given with one single name containing a wildcard;
$!	here we found out the single names
$!
$ wildcard_used:
$!
$	input_file'file_counter' = f$search("''input_file'")
$	if input_file'file_counter' .eqs. ""
$	   then
$		number_of_files = file_counter - 1
$		goto start_run
$	endif
$	file_counter = file_counter + 1
$	goto wildcard_used
$!
$!******************************************************************************


$!******************************************************************************
$!
$!==>	All filenames are now know, so now read them and write the output file
$!
$ start_run:
$!
$	file_counter = 1
$	open/write headers unarc.headers
$	open/write output 'output_file'
$!
$ file_loop:
$!
$	current_file = input_file'file_counter'
$	ws "Processing ''current_file'..."
$	open/read input 'current_file'
$	output = "headers"
$!
$ read_loop:
$!
$	read/end_of_file=end_read input line
$!	if f$locate("+-+-+-",line) .lt. f$length(line) .and. -
!	   f$locate("END",line) .lt. f$length(line) then $ output = "headers"
$	if f$extract(0,6,line) .eqs. "+-+-+-" then $ output = "headers"
$	write 'output' line
$	if f$extract(0,6,line) .eqs. "-+-+-+" then $ output = "output"
$!	if f$locate("+-+-+-",line) .lt. f$length(line) .and. -
!	   f$locate("START",line) .lt. f$length(line) then $ output = "output"
$	goto read_loop
$!
$ end_read:
$!
$	close input
$	file_counter = file_counter + 1
$	if file_counter .gt. number_of_files then $ goto end_run
$	goto file_loop
$!
$!******************************************************************************


$!******************************************************************************
$!
$!==>	All files have been exctracted, now run the created archive file
$!
$ end_run:
$!
$	close headers
$	close output
$	ws "Extract complete, headers are saved in UNARC.HEADERS"
$	subdirect = f$extract(0,f$locate(".",output_file),output_file)
$	ws "Creating directory ''subdirect'"
$	create/dir [.'subdirect']
$	set protect=(s,o:rwed,g,w) 'subdirect'.dir;*
$	set default [.'subdirect']
$	ws "Running ''output_file'"
$	@[-]'output_file'
$	read/end=end/prompt="Delete input files ? (Y/[N]) : " -
	   sys$command del_input
$	if f$edit(f$extract(0,1,del_input),"upcase") .eqs. "Y" then -
	   $ gosub delete_input
$	read/end=end/prompt="Delete output files (including UNARC.HEADERS) ? (Y/[N]) : " -
	   sys$command del_output
$	if f$edit(f$extract(0,1,del_output),"upcase") .eqs. "Y"
$	   then
$		delete/log/noconfirm [-]'output_file';
$		delete/log/noconfirm [-]unarc.headers;
$	endif
$	ws "Unarc complete"
$	goto end
$!
$!******************************************************************************


$!******************************************************************************
$!
$!==>	Give some information on usage
$!
$ give_help:
$!
$	ws "unarc v1.0, Oscar van Eijk, CompuHelp, 20-07-92"
$	ws ""
$	ws "Usage: unarc [-o<output_file>] <input_file(s)> [<input_files>...]
$	ws "       where output_file is optional and at least one input_file"
$	ws "       is required (wildcards allowed)"
$	goto end
$!
$!******************************************************************************


$!******************************************************************************
$!
$!==>	One of the given files is not found; the program exits
$!
$ file_not_found:
$!
$	ws "* File ''check_for_file' not found"
$	goto end
$!
$!******************************************************************************



$!******************************************************************************
$!
$!==>	Something weird happened. A message of the error will be displayed
$!	after which the program exits
$!
$ error_occured:
$!
$	error_status  = "''$status'"
$	error_message = f$message('error_status')
$	on error then $ continue
$	ws ""
$	ws " *** ERROR ***  Some Undefined Error Occured."
$	ws ""
$	ws "-- Status  was  : ''error_status'"
$	ws "-- Message was  : ''error_message'"
$	goto handler
$!
$!******************************************************************************


$!******************************************************************************
$!
$!==>	On errors and interrupts some resets might have to be made
$!
$ handler:
$!
$	set message/nofacility/noidentification/noseverity/notext
$	close input
$	close output
$	close headers
$	set message/facility/identification/severity/text
$	exit
$!
$!******************************************************************************



$!******************************************************************************
$!
$!==>	Well, try to guess what's gonna happen... :-)
$!
$ end:
$!
$	exit
$!
$!******************************************************************************



$!******************************************************************************
$!********************** S U B - R O U T I N E S *******************************
$!******************************************************************************


$!******************************************************************************
$!
$!==>	If all input files have to be deleted; this is the routine that does it
$!
$ delete_input:
$!
$	file_counter = 1
$!
$ delete_loop:
$!
$	file_to_delete = input_file'file_counter'
$	if f$locate(":",file_to_delete) .lt f$length(file_to_delete)
$	   then
$		delete/log/noconfirm 'file_to_delete'
$	   else
$		delete/log/noconfirm [-]'file_to_delete';
$	endif
$	file_counter = file_counter + 1
$	if file_counter .gt. number_of_files then $ return
$	goto delete_loop
$!
$!******************************************************************************
!-------------------------- End UnArc.Com --------------------------------------


---------
 Abandon Hope                                                   Oscar van Eijk
   All Ye                     O x x y                 C&P SON helpdesk, VN-223
Who Enter Here                            Philips Eindhoven, the Net(her)Lands
                                               nl0242t@nlzcl.decnet.philips.nl