echo off
cls
rem
rem	This batch file builds dbase.ovl and
rem	protect.ovl from dBase IV's system disks.
rem
if %1x==x goto usage

:start
if not exist fsize.com goto askdisk
goto havedisk
:askdisk
echo Please insert dBase IV Installation Disk in your disk drive
echo and press any key to continue.
pause >nul
cls
if not exist fsize.com goto usage
:havedisk
fsize @%1
if errorlevel 1 goto setdir
fsize &%1\
if errorlevel 1 goto bstart

copy pkunzip.exe %1\pkunzip.exe > nul
:ok
fsize %1 4
if errorlevel 1 goto space
fsize
if errorlevel 1 goto small
goto loop1

:small
goto sloop1

:loop1
cls
if exist disk1.zip goto ok1
echo Please insert dBase IV System Disk #1 in your disk drive
echo and press any key to continue.
pause >nul				 
if not exist disk1.zip goto loop1
cls

:ok1
echo Installing dbase.ovl and protect.ovl
%1\pkunzip -o disk1.zip %1\ dbase.ov1 >nul
if errorlevel 1 goto setdir

:loop2
cls
echo Please insert dBase IV System Disk #2 in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk2.zip goto loop2
cls

echo Installing dbase.ovl and protect.ovl
%1\pkunzip -o disk2.zip %1\ dbase.ov2 >nul
copy %1\dbase.ov1/B+%1\dbase.ov2 %1\dbase.ov6 >nul
del %1\dbase.ov1 >nul
del %1\dbase.ov2 >nul

:loop3
cls
echo Please insert dBase IV System Disk #3 in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk3.zip goto loop3
cls

echo Installing dbase.ovl and protect.ovl
%1\pkunzip -o disk3.zip %1\ dbase.ov3 >nul
copy %1\dbase.ov6/B+%1\dbase.ov3 %1\dbase.ov7 >nul
del %1\dbase.ov6 >nul
del %1\dbase.ov3 >nul

:loop4
cls
echo Please insert dBase IV System Disk #4 in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk4.zip goto loop4
cls

echo Installing dbase.ovl and protect.ovl
%1\pkunzip -o disk4.zip %1\ dbase.ov4 >nul
%1\pkunzip -o disk4.zip %1\ protect.ovl >nul
copy %1\dbase.ov7/B+%1\dbase.ov4 %1\dbase.ovl >nul
del %1\dbase.ov7 >nul
del %1\dbase.ov4 >nul
goto end

:sloop1
cls
if exist disk1.zip goto sok1
echo Please insert the dBase IV Installation Disk in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk1.zip goto sloop1
cls

:sok1
echo Installing dbase.ovl and protect.ovl
%1\pkunzip -o disk1.zip %1\ dbase.ov1 >nul
if errorlevel 1 goto setdir

:sloop2
cls
if exist disk2.zip if exist disk3.zip goto sok2
echo Please insert dBase IV System Disk #1 in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk2.zip if not exist disk3.zip goto sloop2
cls

:sok2
echo Installing dbase.ovl and protect.ovl
%1\pkunzip -o disk2.zip %1\ dbase.ov2 >nul
%1\pkunzip -o disk3.zip %1\ dbase.ov3 >nul
copy %1\dbase.ov1/B+%1\dbase.ov2/B+%1\dbase.ov3 %1\dbase.ov6 >nul
del %1\dbase.ov1 >nul
del %1\dbase.ov2 >nul
del %1\dbase.ov3 >nul

:sloop3
cls
if exist disk4.zip goto sok3
echo Please insert dBase IV System Disk #2 in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk4.zip goto sloop3
cls

:sok3
echo Installing dbase.ovl and protect.ovl
%1\pkunzip -o disk4.zip %1\ dbase.ov4 >nul
%1\pkunzip -o disk4.zip %1\ protect.ovl >nul
copy %1\dbase.ov6/B+%1\dbase.ov4 %1\dbase.ovl >nul
del %1\dbase.ov6 >nul
del %1\dbase.ov4 >nul
goto end

REM **************************************
:bstart
copy pkunzip.exe %1pkunzip.exe > nul
:bok
fsize %1 4
if errorlevel 1 goto space
fsize
if errorlevel 1 goto bsmall
goto bloop1

:bsmall
goto bsloop1

:bloop1
cls
if exist disk1.zip goto bok1
echo Please insert dBase IV System Disk #1 in your disk drive
echo and press any key to continue.
pause >nul				 
if not exist disk1.zip goto bloop1
cls

:bok1
echo Installing dbase.ovl and protect.ovl
%1pkunzip -o disk1.zip %1 dbase.ov1 >nul
if errorlevel 1 goto setdir

:bloop2
cls
echo Please insert dBase IV System Disk #2 in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk2.zip goto bloop2
cls

echo Installing dbase.ovl and protect.ovl
%1pkunzip -o disk2.zip %1 dbase.ov2 >nul
copy %1dbase.ov1/B+%1dbase.ov2 %1dbase.ov6 >nul
del %1dbase.ov1 >nul
del %1dbase.ov2 >nul

:bloop3
cls
echo Please insert dBase IV System Disk #3 in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk3.zip goto bloop3
cls

echo Installing dbase.ovl and protect.ovl
%1pkunzip -o disk3.zip %1 dbase.ov3 >nul
copy %1dbase.ov6/B+%1dbase.ov3 %1dbase.ov7 >nul
del %1dbase.ov6 >nul
del %1dbase.ov3 >nul

:bloop4
cls
echo Please insert dBase IV System Disk #4 in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk4.zip goto bloop4
cls

echo Installing dbase.ovl and protect.ovl
%1pkunzip -o disk4.zip %1 dbase.ov4 >nul
%1pkunzip -o disk4.zip %1 protect.ovl >nul
copy %1dbase.ov7/B+%1dbase.ov4 %1dbase.ovl >nul
del %1dbase.ov7 >nul
del %1dbase.ov4 >nul
goto end

:bsloop1
cls
if exist disk1.zip goto bsok1
echo Please insert the dBase IV Installation Disk in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk1.zip goto bsloop1
cls

:bsok1
echo Installing dbase.ovl and protect.ovl
%1pkunzip -o disk1.zip %1 dbase.ov1 >nul
if errorlevel 1 goto setdir

:bsloop2
cls
if exist disk2.zip if exist disk3.zip goto bsok2
echo Please insert dBase IV System Disk #1 in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk2.zip if not exist disk3.zip goto bsloop2
cls

:bsok2
echo Installing dbase.ovl and protect.ovl
%1pkunzip -o disk2.zip %1 dbase.ov2 >nul
%1pkunzip -o disk3.zip %1 dbase.ov3 >nul
copy %1dbase.ov1/B+%1dbase.ov2/B+%1dbase.ov3 %1dbase.ov6 >nul
del %1dbase.ov1 >nul
del %1dbase.ov2 >nul
del %1dbase.ov3 >nul

:bsloop3
cls
if exist disk4.zip goto bsok3
echo Please insert dBase IV System Disk #2 in your disk drive
echo and press any key to continue.
pause >nul
if not exist disk4.zip goto bsloop3
cls

:bsok3
echo Installing dbase.ovl and protect.ovl
%1pkunzip -o disk4.zip %1 dbase.ov4 >nul
%1pkunzip -o disk4.zip %1 protect.ovl >nul
copy %1dbase.ov6/B+%1dbase.ov4 %1dbase.ovl >nul
del %1dbase.ov6 >nul
del %1dbase.ov4 >nul

REM **************************************
:end
cls
echo dBase IV's overlay installation completed.
goto out

:setdir
echo ERROR: %1 does not exist. Please enter a VALID directory!
goto out

:usage
echo To install dBASE IV's overlays, you must run DBASEOVL
echo from the disk drive that contains dBASE IV Install Disk.
echo Type: DBASEOVL [DRIVE:\PATH] and press Enter
echo [DRIVE:\PATH] must exist on your system.
goto out

:space
echo dBASE IV's overlays require 4 Megabytes (MB) of
echo space on your hard disk. Please remove unneeded
echo files from the drive where you want dBASE to be 
echo and try again.

:out		      



