/* $VER: 2.00 convert lha to lzx 

  Use with opus to convert ONE file at a time from lha to lzx.

  Create a button named LHA->LZX saying

  AmigaDOS    rx dopus:modules/rexx/conv.lha->lzx.rexx {f}

  FLAGS:
  Do all files
  No filename quote
  Output window
  Rescan source
  
  script will delete the extracted files and
  delete the original file (.lha that is)


  OR use from a shell
*/

ARG file

if ~show(l,"rexxsupport.library") then
call addlib("rexxsupport.library",0,-30,0)

if file = '' then signal usage
if file = '?' then signal usage

test = right(file,3)
if test ~= 'LHA' then signal NOPE
else say 'LHA to LZX by Niels <ABC>...working on -> 'file

NewFile = Left(File,Length(file)-3)'lzx'
makedir('sys:repack')

Address COMMAND 'c:assign repack: sys:repack'
Address COMMAND 'delete repack:#? all force >nil:'
Address COMMAND 'c:LHA -a -F -M x' file '#? REPACK:'
Address COMMAND 'c:LZX -r -e -M500 -3 -F a ' newfile 'repack:#?'
Address COMMAND 'delete' file '>nil:'
Address COMMAND 'c:assign repack: remove'
Address COMMAND 'c:delete sys:repack all >nil:'
EXIT

USAGE:

say "USAGE: rx conv.lha->lzx [file].lha"
say 
say
say "Will convert a single LHA-archive to LZX."
say "AND delete the original LHA file..."
say "(p) niels >ABC<"
EXIT

NOPE:
say 'I need a lha file to work on, so'
say file 
say 'will not work. Sorry !'
say
EXIT