/* Arexx! */
verstr="$VER: Repack-multiselector V0.2 by Andrea Vallinotto (16.7.96)"

parse arg pubscreen . /* Can be expanded to something more fancy if needed */

options results
parse var verstr skip utname vers .

call setuplib("rexxreqtools.library",0,-30,0)
call setuplib("rexxsupport.library",0,-30,0)
cr='0a'x
filelistname='T:Repack.filelist'
taglist='rtfi_flags=freqf_multiselect|freqf_selectdirs rtfi_matchpat='
rttaglist='rtez_flags=ezreqf_centertext'
cmdline="rexx:repack/3.5/repack USE_FILELIST!"

if (pubscreen~=='') then	do
				pubtag = 'rt_pubscrname='pubscreen
				taglist=pubtag taglist
				rttaglist=pubtag rttaglist
				end
if (rtezrequest('Do you want to repack'cr'LZX archives too ?','_No|_Yes',utname vers,rttaglist)) then  force = 0
											else force = 1

reqtext='Pick as many files and/or directories'cr'as you want.'cr"Select 'Cancel' when you've done."

call rtezrequest(reqtext,'_Ok..',utname vers,rttaglist)

if force then taglist=taglist||"#?.(LZX|LZH|LHA|ZIP|ARJ|RAR|SHR|XAR|HPK|ARC|ZOO|PAK|TAR|GZ|Z|TGZ)"
	else taglist=taglist||"#?.(LZH|LHA|ZIP|ARJ|RAR|SHR|XAR|HPK|ARC|ZOO|PAK|TAR|GZ|Z|TGZ)"

call open(flist,filelistname,W)
total=0
do while(rtfilerequest(,,'Multiselect: Pick files or dirs','_Add',taglist,'files')~=='')
	total=total+files.count
	do i = 1 to files.count
		if(files.i~='') then Call WriteLN(flist,files.i)
	end
end
Call close(flist)
if(total>0) then if(force) then address command 'rx' cmdline 'FORCE'
		else address command 'rx' cmdline
else	do
	say "No file(s) selected!"
	Call Delete(filelistname)
	end
exit 0


setuplib: procedure
parse arg library,v1,v2,v3

if(~show('l',library))then	do
				if(~addlib(library,v1,v2,v3))then	do
									say "Could not open" library"! Aborting..."
									exit 10
									end
				end
return 1
