RequestFile >env:orig TITLE "Full path of drawer of archive?" DRAWERSONLY NOICONS DRAWER "$o" ;Saves the location of the archive in the environment variable 'orig', with the default path as that of the last archive if converting more
if WARN
skip end
endif
echo >env:o $orig ;Get rid of quotation marks, and also create default path for next archive if converting more
list >env:osz env:o LFORMAT=%L ;Get size of path name
if "$osz" EQ "1" ;Full path not selected
RequestChoice > NIL: "! Error !" "Choose FULL path!*n(i.e. start with DEVICE listing)" "Try again"
skip Path BACK
endif
lab File
RequestFile >env:ldfl TITLE "Chose file to convert" POSITIVE Convert ACCEPTPATTERN #?.(lha|lzx) DRAWER $orig ; $ldfl now contains the complete path and filename of the archive
if WARN
skip More
endif
echo >env:l $ldfl ;Get rid of quotation marks
list >env:lsz env:l LFORMAT=%L ;Get size of file name
basename >env:bnm1 $ldfl ;Strips the path of the archive to give only the filename with suffix
basename >env:bnm $bnm1 .lzx ;Removes .lzx suffix from filename if it has it
lab Temp
RequestChoice >env:drw "Default directory" "Where should I store temporary files? A*ntemporary drawer called 'L2Z' will be*ncreated in your selected destination, and*nRAM: will be checked for space if chosen" "RAM:" "Other" "Cancel"
if $drw EQ 1 ;If the left button (i.e. RAM:) is chosen
echo RAM: >env:drw1
endif
if $drw EQ 2 ;If "Other" is chosen
RequestFile >env:drw1 TITLE "Where should 'L2Z' be made?" DRAWERSONLY NOICONS POSITIVE Create
if WARN
skip More
endif
endif
if $drw EQ 0 ;If "Cancel" is chosen
skip More
endif
lab Memchk
set memsz `avail flush total`
cd $orig
list >env:flsz $ldfl LFORMAT=%L
eval >env:flmem $flsz * 4
if NOT $memsz VAL GT $flmem ;If you have less memory than predicted will be needed
if $drw1 EQ RAM:
RequestChoice >env:nomem "! Insufficient Memory!" "There may be insufficient memory to store temporary files in RAM:*n(may need at least $flmem bytes)" "Choose other path" "Continue anyway" "Cancel"
if $nomem EQ 0 ;"Cancel"
skip More
endif
if $nomem EQ 1 ;"Other"
skip Temp back
endif
if $nomem EQ 2 ;"Continue"
skip MkTemp
endif
endif
if "$drw1" EQ "Ram Disk:" ;If user clicks on RAM: in file requestor
RequestChoice >env:nomem "! Insufficient Memory!" "There may be insufficient memory to store temporary files in RAM:*n(may need at least $flmem bytes)" "Choose other path" "Continue anyway" "Cancel"
if $nomem EQ 0 ;"Cancel"
skip More
endif
if $nomem EQ 1 ;"Other"
skip Temp back
endif
if $nomem EQ 2 ;"Continue"
skip MkTemp
endif
endif
endif
lab MkTemp
cd $drw1
if NOT EXISTS l2z ;This creates a temporary drawer in which to de-archive the files in the archive
makedir > NIL: l2z
else ;Drawer is emptied if it is already there
delete l2z/#? FORCE QUIET
endif
lab extra
RequestChoice >env:ext "Convert $l to . . ." "Do you want to convert to the other*nfiletype or to the smallest archive?*n*nConvert to:" "Other" "Smallest" "Cancel"
if WARN ;If 'Cancel' is selected
skip beg BACK ;This skips back to the section labelled 'Beg', at the beginning
endif
if $ext EQ 2 ;If the user wants to make the smallest archive
skip Conv ;This skips forward to the section labelled 'Conv'
endif
if $ext EQ 1 ;If the user wants to convert to the other format - original format is found and is intelligently converted to the other
if $bnm1 EQ $bnm ;Means it is an LhA archive
delete env:bnm QUIET
basename >env:bnm $bnm1 .lha
cd $drw1
cd l2z
$wlha x -a $ldfl
if $RC EQ 20 ;If user aborts it will skip to 'More'
skip More
endif
$wlzx -r -e -3 a $bnm #?
if $RC EQ 50 ;If user aborts it will skip to 'More'