. $VER: HipPack 1.2a (16.11.96)  1996 Jari Karjalainen <jaka@sci.fi>
.key File1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,Work/K,ALL/S
.bra {
.ket }
.def work eimitn
.def File1 eimitn
set mods "#?.mod|mod.#?|#?.s3m|s3m.#?|#?.xm|xm.#?|#?.med|med.#?|#?.mtm|mtm.#?"
set pack "#?.lha|#?.lzh|#?.lzx|#?.zip|#?.arj|#?.rar"
set hippackver "HipPack 1.2a  1996 Jari Karjalainen"
if {work} eq eimitn
  if exists env:hpwork
  set work "$hpwork"
  else
  set work T:
  endif
else
set work "{work}"
endif
if {all}
set all yes
else
  if "$hpplay" eq all
  set all yes
  endif
endif
if not exists env:hpckdef
setenv hpckdef SYS:
endif
lab alku
unset end
setenv nro 1
if not "{File1}" eq EiMitn
echo "{File1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12} {13} {14} {15} {16}" >env:file0
else
requestfile title="Select archive(s) or/and module(s)..." "$hpckdef" multiselect positive=HiP acceptpattern="($pack|$mods)" >env:file0
endif
failat 11
if "$file0" eq "" >nil:
  if not error
  skip end
  endif
endif
tr <env:file0 >env:h2
failat 21
list $h2 lformat %p >nil:
if fail
  if exists c:requestchoice
  requestchoice >nil: "$hippackver" "Hmm jotain meni pieleen...*n*nEsim. tiedostonimiss saattaa olla*nvlilyntej tai erikoismerkkej,*njotka eivt oikein ole hyv juttu*nmuutenkaan." "No pahus"
  else
  echo "[1m$hippackver[0m*nHmm jotain meni pieleen...*n*nEsim. tiedostonimiss saattaa olla vlilyntej tai erikoismerkkej,*njotka eivt oikein ole hyv juttu muutenkaan."
  endif
skip end
else
list "$h2" lformat "%p" >env:hpckdef
endif
copy >nil: env:hpckdef envarc:
search >nil: env:h2 ($mods) pattern
if not warn
Hip `search env:h2 ($mods) pattern nonum`
waithip
endif
search >nil: env:h2 ($pack) pattern
if not warn
search env:h2 ($pack) pattern nonum >t:h.0
type t:h.0 >t:h.p number
else
set end no
skip end
endif
lab etsi
search >nil: t:h.p "  $nro "
if not warn
setenv file `search t:h.p "   $nro " quick nonum`
setenv file `echo "$file" first 3`
setenv nro `eval $nro+1`
else
  if "$all" eq yes
  set allmods yes
  skip playpack
  endif
set end no
skip end
endif
lab chkpack
setenv packf "$file"
if exists "$Work"
assign >nil: hipwr: "$Work"
else
assign >nil: hipwr: T:
endif
if not exists hipwr:tmpdir{$$}
makedir hipwr:tmpdir{$$}
endif
failat 21
search >nil: env:packf .(lha|lzh) pattern
if not warn
lha -qx2 e "$file" hipwr:tmpdir{$$}/
else
  search >nil: env:packf .zip
  if not warn
  unzip -qoj "$file" -d hipwr:tmpdir{$$}/
  else
    search >nil: env:packf .lzx
    if not warn
    lzx -q1x0 e "$file" hipwr:tmpdir{$$}/
    else
      search >nil: env:packf .arj
      if not warn
      assign >nil: hippsrc: ""
      cd hipwr:tmpdir{$$}/
      unarj >nil: e "$file"
      cd hippsrc:
      assign >nil: hippsrc: remove
      else
        search >nil: env:packf .rar
        if not warn
        assign >nil: hippsrc: ""
        cd hipwr:tmpdir{$$}/
        unrar >nil: e -o+ "$file"
        cd hippsrc:
        assign >nil: hippsrc: remove
        else
        set end no
        skip end
        endif
      endif
    endif
  endif
endif
if "$all" eq yes
skip back etsi
endif
lab playpack
Hip `list hipwr:tmpdir{$$}/($mods) lformat "*"%p%n*""`
waithip
delete >nil: hipwr:tmpdir{$$} all
assign >nil: hipwr: remove
if "$all" eq yes
  if $allmods eq yes
  unset $allmods
  set end no
  skip end
  endif
endif
skip back etsi
lab end
unsetenv file
unsetenv packf
delete >nil: t:h.?
unsetenv nro
unsetenv h2
unsetenv file0
unsetenv file
if $end eq no
  if "{File1}" eq eimitn
  skip back alku
  endif
endif
unset work
unset all
unset mods
unset pack
run >nil: delete >nil: t:command-??-t{$$}
