#
#   pack.sh  -  add to a new archive
#
set file $_passed
# Uncomment the following line if the default destination directory should
# be where the archive came from:
#

alias center "%a echo @center( $a 77 )

if $file <> ""
 class.sh toolmanager
 set toadd ""
 set arc   ""
 set lharc lharc

 foreach i ( $file ) {
  if @getclass( $i ) = $lharc
   set arc $i
   set lharc xxx
  else
   set toadd $toadd $i
  endif
 }

 if -n $arc
  set destdir @pathname( @first( $toadd ) )
  if @words( $toadd ) = 1
   set default @basename( $toadd )
   set default $default.LZH
  endif
  tackon pattern $destdir "*.lzh"
  set arc @filereq( "Archive to add to:" $pattern $default )
 endif

 if $arc
  set   destdir @pathname( $arc )
  cd   $destdir
  lharc a $arc $toadd 
 endif

else
 center
 center "* * *  PACK  * * *"
 center
 center "If you select a set of icons with an LHarc archive among them, the
 center "files will be added to the archive. If no archive is among them,
 center "you can select an archive name from a file requester.
 center
 center "You have to select 'Update' from the workbench's 'Window' menu to
 center "see the new file if the destination drawer was already open.
 center
 center "To modify the program used for archiving, read the
 center "chapter 'object oriented features' in your csh.doc.
 center
 center "Click close button when done
endif
