home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1995 November
/
PCWK1195.iso
/
inne
/
podstawy
/
dos
/
4dos
/
4uzytki
/
mav120.exe
/
MAV.BTM
Wrap
Text File
|
1992-10-29
|
12KB
|
357 lines
@echo off
setlocal
unalias *
goto env_space
: ┌───────────────────── Information ──────────────────────┐
: │ │
: │ This is Mally's Archive Viewer. The purpose of this │
: │ program is to facilitate viewing the contents of a │
: │ so called archive without having to remember the │
: │ parameters and without having to clean up the mess │
: │ after you finish. │
: │ │
: │ This is a Batch To Memory (btm) file, │
: │ which means that it is a very fast batch file that │
: │ will only run if 4DOS is your command interpreter. │
: │ Moreover, it is assumed that you use 4DOS version │
: │ 4.0 or later. 4DOS is a shareware program, available │
: │ at almost every BBS and `anonymous FTP' site. │
: │ │
: │ Of course, you are free to make as many changes in │
: │ this program as you like. If you do, please change │
: │ the name of the file and remove my name (%MYNAME). │
: │ │
: │ If you have any remarks, questions or suggestions, │
: │ E-mail me at │
: │ MALLY@eco.rug.nl │
: │ │
: └────────────────────────────────────────────────────────┘
:installation
: ┌───────────────────── Installation ─────────────────────┐
: │ │
: │ Fill in the path to your archivers, e.g. │
set ARCPATH=y:;g:\utils\zip;g:\utils\arj
: │ (Only needed if not already in path) │
: │ │
: │ Fill in the archive extensions known to your system │
: │ ( any of [arc,arj,lzh,zip,zoo] ), e.g. │
set ARCTYPES=arc;arj;lzh;zip;zoo
: │ MAV uses the following programs to handle archives: │
: │ arc : PKUNPAK (PKWARE Inc.) │
: │ arj : ARJ (Robert K. Jung) │
: │ lzh : LHA (Haruyasu Yoshizaki) │
: │ zip : PKUNZIP (PKWARE Inc.) │
: │ zoo : ZOO (Rahul Dhesi) │
: │ │
: │ Fill in the working directory, i.e. the directory │
: │ where some temporary files will be written │
set WORKINGDIR=g:\mav
: │ │
: │ Define the parameter DOCU, i.e. indicate the │
: │ files to `show only' if this parameter is used │
set DOCU=*.doc *.txt *.me *.man *.bat *.btm
: │ │
: │ Colors used in selection windows are set by the │
: │ HistWinColor directive in 4DOS.INI. │
: │ │
: └────────────────────────────────────────────────────────┘
: ┌────────────────────── History ─────────────────────────┐
: │ │
: │ v1.2 Changed name to MAV. │
: │ Minimized amount of free environment space │
: │ needed at start-up. │
: │ Check on existence of WORKINGDIR added. │
: │ Can now handle full pathnames in ZIP files. │
: │ Parameter DOCU added. │
: │ v1.1 Several improvements. Donated to the │
: │ public domain. │
: │ v1.02 Changed listing technique of archives │
: │ (much faster) │
: │ v1.01 Minor alterations and bug fixes │
: │ v1.00 First release for very small public │
: │ │
: └────────────────────────────────────────────────────────┘
goto continue
:env_space
: This is a trick to assure enough environment space under almost all
: circumstances. MAV needs 20 bytes of environment space to start but
: approximately 512 bytes to run. If not enough space is available,
: MAV reloads itself in a secondary shell.
: Under exceptional circumstances it is possible that 512 bytes are not
: enough to run. The solution is to increase the value of ES, set below.
if %_env LT 20 goto error_memory
set ES=512 >& nul
if "%1"=="/run" goto installation
if %_env GE %ES goto installation
%COMSPEC //EnvFree=%ES /c %0 /run %& >&> nul
goto end
:continue
set VERSION=v1.2
set MYNAME=Mally
iff "%1"=="/run" then
if %#==1 goto syntax
shift 1
else
if %#==0 goto syntax
endiff
if "%_4ver"=="" set _4ver=0
iff %_4ver LT 4.0 then
echo.
echo Sorry, need 4DOS version 4.0 or higher to run.
goto end
endiff
keystack !
if "%ARCPATH" NE "" path %ARCPATH%;%PATH%
set ARCHIVE=%1
iff %@eval[%@index[%ARCHIVE,.]+1]==%@len[%ARCHIVE] then
set ARCHIVE=%@substr[%ARCHIVE,0,%@index[%ARCHIVE,.]]*.*
endiff
set SHOWONLY=%2&
if "%@upper[%SHOWONLY]"=="DOCU" set SHOWONLY=%DOCU
if "%@substr[%WORKINGDIR,0,-1]" NE "\" set WORKINGDIR=%WORKINGDIR%\
iff NOT isdir %WORKINGDIR then
echo.
echo The working directory %@upper[%WORKINGDIR] does not exist.
inkey /K"YyNn" Should it be created? (y/n) %%CHAR
iff "%@upper[%CHAR]"=="N" then
echo Directory NOT created.
shift -1
echo See file %@upper[%@search[%0]] for installation directives.
quit
endiff
md %WORKINGDIR
endiff
set LIST=%@unique[%WORKINGDIR]
set LISTING=%@unique[%WORKINGDIR]
set DELFILES=%LIST %LISTING
pushd
cdd %@path[%ARCHIVE] >& NUL
set ARCDIR=%_cwds
set ARCHIVE=%@name[%ARCHIVE]%.%@ext[%ARCHIVE]
if "%@ext[%ARCHIVE]"=="*" set ARCHIVE=%@name[%ARCHIVE]
iff "%@ext[%ARCHIVE]"=="" then
if %@index[%ARCTYPES%,arc] GE 0 set ATYPES=%ARCHIVE%.arc;
if %@index[%ARCTYPES%,arj] GE 0 set ATYPES=%ATYPES%%ARCHIVE%.arj;
if %@index[%ARCTYPES%,lzh] GE 0 set ATYPES=%ATYPES%%ARCHIVE%.lzh;
if %@index[%ARCTYPES%,zip] GE 0 set ATYPES=%ATYPES%%ARCHIVE%.zip;
if %@index[%ARCTYPES%,zoo] GE 0 set ATYPES=%ATYPES%%ARCHIVE%.zoo;
set ARCTYPES=%ATYPES%
set ATYPES=
dir %ARCTYPES /bfOn > %LISTING >&> NUL
else
dir %ARCHIVE /bfOn > %LISTING >&> NUL
endiff
:more
iff %@lines[%LISTING] GE 1 then
set ARCHIVE=%@select[%LISTING,0,0,25,80, Mally's Archive Viewer %VERSION ]
set MORE=more
else
set ARCHIVE=%@line[%LISTING,0]
endiff
if "%ARCHIVE"=="" goto thanks
if "%ARCHIVE"=="**EOF**" goto no_archives
if "%ARCHIVE"=="*.*" goto no_archives
iff "%@ext[%ARCHIVE]"=="arc" then
set ARCHIVER=pkunpak
set VIEW=-v
set POSITION=0
set LENGTH=,13
set EXTRACT=-e
set KEYSTACK=down down down down down down down down
goto main
endiff
iff "%@ext[%ARCHIVE]"=="arj" then
set ARCHIVER=arj
set VIEW=l
set POSITION=0
set LENGTH=,13
set EXTRACT=e
set KEYSTACK=down down down down down down down
goto main
endiff
iff "%@ext[%ARCHIVE]"=="lzh" then
set ARCHIVER=lha
set VIEW=-l
set POSITION=2
set LENGTH=,13
set EXTRACT=e
set KEYSTACK=down down down down down
goto main
endiff
iff "%@ext[%ARCHIVE]"=="zip" then
set ARCHIVER=pkunzip
set VIEW=-v
set POSITION=61
set LENGTH=
set EXTRACT=-e
set KEYSTACK=down down down down down down down down down
goto main
endiff
iff "%@ext[%ARCHIVE]"=="zoo" then
set ARCHIVER=zoo
set VIEW=-list
set POSITION=49
set LENGTH=,13
set EXTRACT=-extract
set KEYSTACK=down down down down
goto main
endiff
goto error
:main
cdd %WORKINGDIR >& NUL
del %LIST >& NUL
%ARCHIVER %VIEW %ARCHIVE %SHOWONLY > %LIST >&> NUL
if ERRORLEVEL 1 goto error_unarchive
:again
keystack %KEYSTACK
set SHOW=%@substr[%@select[%LIST,0,0,25,80, Mally's Archive Viewer %VERSION ],%POSITION%%LENGTH]
:slash
iff %@index[%SHOW,/] GE 0 then
set SHOW=%@substr[%SHOW,0,%@eval[%@index[%SHOW,/]]]\%@substr[%SHOW,%@eval[%@index[%SHOW,/]+1],256]
goto slash
endiff
iff "%SHOW" NE "" then
set SHOWFILE=%@name[%SHOW].%@ext[%SHOW]
iff NOT exist %ARCDIR%%SHOW then
iff NOT exist %SHOWFILE then
%ARCHIVER %EXTRACT %ARCHIVE %SHOW >& NUL
set DELFILES=%DELFILES %@full[%SHOWFILE]
endiff
endiff
goto list
endiff
goto %MORE
goto thanks
:list
iff NOT exist %ARCDIR%%SHOWFILE then
list %SHOWFILE
else
iff exist %ARCDIR%%SHOWFILE then
list %ARCDIR%%SHOWFILE
else
goto error
endiff
endiff
cls
goto again
:thanks
echo.
echos Thanks for using` `
scrput %_row %_column bright white on red %MYNAME's Archive Viewer %VERSION` `
echo.
goto end
:syntax
echo.
echos Syntax of` `
scrput %_row %_column bright white on red %MYNAME's Archive Viewer %VERSION` `
echo.
echo.
echo %@upper[%@name[%0]] archive[.ext] [showonly.xtn [showonly.xtn] [DOCU]]
echo.
echo where
echo - archive is a filename
echo - ext is one of %ARCTYPES
echo - showonly is a filename
echo - xtn is an extension
echo - DOCU may be used to show only files with
echo. mask in %DOCU
echo.
echo Wildcards: * is allowed everywhere,
echo ? everywhere except in ext
echo.
echo See file %@upper[%@search[%0]] for installation directives
goto end
:error
gosub error_screen
del %DELFILES >& NUL
iff %@diskfree[%_disk,K] LT 200 then
echo Most likely, the error occurred because of insufficient free disk
echo space on your working drive %_disk: (there is only %@diskfree[%_disk,K]K free).
echo.
echo Otherwise, the reason is that
endiff
echo %@upper[%ARCHIVE] does not exist, is corrupted,
echo is not an archive, or its archive method is unknown.
goto end
:error_unarchive
iff "%@search[%ARCHIVER]"=="" then
gosub error_screen
echo The program %@upper[%ARCHIVER%], needed to handle archives with extension .%@upper[%@ext[%ARCHIVE]],
echo was not found.
echo.
goto end
endiff
iff "%MORE" NE "" then
cls
drawbox 0 10 3 70 1 bri whi on red fill red
scrput 1 15 bri whi on red %@upper[%ARCHIVE]
scrput 2 15 bri whi on red does not contain a file with extension %@upper[%@ext[%SHOWONLY]]
screen 4 10
pause
cls
goto %MORE
else
gosub error_screen
echo %@upper[%ARCHIVE] does not contain a file with extension %@upper[%@ext[%SHOWONLY]]
echo.
goto end
endiff
:no_archives
gosub error_screen
echo No archives in directory %@path[%1]
goto end
:error_memory
echo.
echo Not enough environment space. MAV needs 20 bytes to start.
echo.
goto end
:error_screen
echo.
echos Error reported by` `
scrput %_row %_column bright white on red %MYNAME's Archive Viewer %VERSION` `
echo.
echo.
return
:end
cdd %WORKINGDIR >& NUL
del %DELFILES >& NUL
popd >& NUL