@echo off
setlocal^unalias *
alias clb `drawbox 0 0 %1 79 0 %tcolor fill %bg`
alias clr clb 23
alias clr2 clb 24
alias box `clr^screen %1 %lcol^drawbox %1 %lcol %2 %rcol 2 %hcolor fill %bg`
alias put `scrput %1 %tcol %tcolor %2`
alias puth `scrput %1 %tcol %hcolor %2`
alias setin `scrput %1 %2 %tcolor %3&^screen %1 %2`
alias inp `setin %1 %2 %3^input %%in`
alias ink `setin %1 %2 %3^inkey %%in`
alias inreq `scrput %1 %tcol %pcolor %2&`
alias keywait `inreq %1 `Press X to exit, any other key to continue ...`^ink %1 %kcol `    `^if "%in"=="X" goto %2`
alias keywait2 `inreq %1 `Press any key to continue ...`^ink %1 %kcol2 `    ``
alias upper `set %1=%@upper[%[%1]]`
alias trunc `set %1=%@upper[%@substr[%[%1],0,1]]`
alias bp beep 659 2
alias ask `bp^echo.^input %& %%in^trunc in`
alias ask1 `inreq %1 %3^inp %1 %2 `    `^trunc in`
alias getdir `set dir=%[%1]^set row=%2^gosub GET_DIR^set %1=%dir >& nul`
alias errclr `scrput 24 0 %tcolor `                                                                           ``
alias error `beep 880 3^scrput 24 %lcol %ecolor %1^goto %2`
alias dirchk `if "%dlook"=="N" dcerr`
alias dcerr `error `You must set the installation directories first` MAINMENU`
alias setdir `cdd %1^if diskfree lt %2 dirfull %3`
alias dirfull `beep 880 3^echo.^echo   There is not enough room on your disk to install these files^goto %1`
iff "%1"=="" then^set sd=A^else^set sd=%1^trunc sd^endiff
iff "%2"=="" then^set td=C^else^set td=%2^trunc td^endiff
set dlook=N^set i286=N^set lcol=4^set rcol=75^set tcol=8^set kcol=55^set kcol2=38
set tcolor=whi on bla^set hcolor=bri whi on bla^set pcolor=bri whi on bla^set ecolor=bri whi on bla^set bg=bla
iff not video==mono then
   iff not monitor==mono then
      set tcolor=whi on blu^set hcolor=bri whi on blu^set pcolor=bri yel on blu^set ecolor=bri red on blu^set bg=blu
   endiff
endiff
iff "%td" GE "C" then
  set udir=\4dos^set ddir=\4dos
else
  set udir=\^set ddir=\
endiff
set sdir=%td:\^set udir=%td:%udir^set ddir=%td:%ddir
color %tcolor^clr^errclr
box 1 24
puth 03 `                          Introduction`
put  05 `Welcome, and thanks for trying 4DOS!`
put  07 `Using a menu system implemented entirely in 4DOS's powerful`
put  08 `batch file language, INSTALL will allow you to:`
put  10 `        * Set the directories for 4DOS files`
put  12 `        * Copy the 4DOS files to your boot disk`
put  14 `        * Create a file containing the changes you need to`
put  15 `          make in CONFIG.SYS to boot your system with 4DOS`
put  17 `        * View and / or print the 4DOS manual and other`
put  18 `          documentation`
put  20 `        * Brand your registered copy of 4DOS`
keywait 22 UEXIT^clr2
box 5 18
puth 07 `              Registered Copy Information`
put  09 `This procedure can be used to install both registered and `
put  10 `shareware copies of 4DOS.`
put  12 `If you have a registered copy of 4DOS, INSTALL will allow you`
put  13 `to run the BRAND program to convert your 4DOS shareware files`
put  14 `into a registered version of the program.`
ask1 16 54 `Do you have a registered copy of 4DOS (Y/N)?`
set reg=%in^iff "%in" NE "Y" then
  box 1 23
  puth 03 `                      Shareware Information`
  put  05 `After installing a shareware copy of 4DOS you may try it`
  put  06 `for up to 21 days before deciding whether you want to`
  put  07 `continue using it and pay the registration fee.  After this`
  put  08 `time you are required to either register 4DOS or stop using it,`
  put  09 `as specified in the 4DOS license agreement.  This method of`
  put  10 `marketing, known as "shareware", allows you to try 4DOS to`
  put  11 `determine whether it meets your needs before you pay for it.  `
  put  13 `For more information on registration and the license agreement,`
  put  14 `see the 4DOS manual, or the files README.DOC and ORDER.FRM.`
  put  16 `You may make copies of the shareware version of 4DOS for others`
  put  17 `to try.  Never copy the registered version of 4DOS for others. `
  put  18 `If you run a shareware disk library, see the VENDOR.DOC file`
  put  19 `for distribution information.`
  keywait 21 UEXIT
endiff
iff "%reg"=="Y" then
  set m_end=22^set m_ask=20^set m_exit=17
else
  set m_end=20^set m_ask=18^set m_exit=15
endiff
:MAINMENU
box 2 %m_end
puth 04 `                         4DOS INSTALL Main Menu`
put  06 `                1 - Set directories for 4DOS files`
put  08 `                2 - Copy the 4DOS files`
put  10 `                3 - View / print the manual and`
put  11 `                    other documentation`
put  13 `                4 - Create CONFIG.SYS modifications`
iff "%reg"=="Y" then
  put  15 `                5 - Brand a registered copy of 4DOS`
endiff
put  %m_exit `                X - Exit INSTALL`
ask1 %m_ask 44 `             Enter your selection:`^set msel=%in^errclr
if "%msel" NE "1" goto NOT1
  box 3 19
  puth 05 `                  Directory Selection Caution`
  put  07 `If you are upgrading from a previous version of 4DOS, be sure`
  put  08 `to install the version 3.03 files in a DIFFERENT directory from`
  put  09 `the one your current 4DOS files are stored in.  After you have`
  put  10 `looked at the documentation and read about the changes in version`
  put  11 `3.03, you can copy the new files to your usual directories, and`
  put  12 `reboot your system with version 3.03 of 4DOS.`
  put  14 `View or print the README.DOC file for more information on`
  put  15 `upgrading from a previous version to version 3.03.`
  keywait 17 MAINMENU
  box 2 23
  puth 04 `                       Directory Selection`
  put  06 `4DOS's system (executable) files normally go in the root`
  put  07 `directory of your boot disk.  Directory for system files:`
  put  09 ``
  put  11 `Utility files normally go in their own directory.  You`
  put  12 `should modify your PATH statement in AUTOEXEC.BAT to`
  put  13 `include this directory.  Directory for utility files:`
  put  15 ``
  put  17 `Documentation files may go in any directory you like.  You`
  put  18 `must select a directory for these files if you want to`
  put  19 `view or print them.  Directory for documentation files:`
  put  21 ``
  getdir sdir 9
  iff %@len[%sdir] GT 3 then^set udir=%sdir^set ddir=%sdir^endiff
  getdir udir 15^getdir ddir 21
  upper sdir^upper udir^upper ddir^set dlook=Y
  goto MAINMENU
:NOT1
if "%msel" NE "2" goto NOT2
  dirchk^set zn=%sd:pkunzip.exe^set tdisk=%@substr[%udir,0,2]
  if "%tdisk"=="A" goto DOCOPY^if "%tdisk"=="B" goto DOCOPY^if %@substr[%_dosver,0,1]==2 goto DOCOPY
  copy %zn %udir\ >&nul^if exist %udir\pkunzip.exe set zn=%udir\pkunzip.exe
:DOCOPY
  cls^echo.^echo.^echo UnZIPping (decompressing) the 4DOS files ...^echo.
  echo If a file already exists, you will be prompted by the unzip program
  echo for whether to overwrite it.
  iff "%3"=="5" then
    iff "%reg"=="Y" then
      echo.^echo --> Your registered copy of 4DOS on 5.25 inch disks has the files
      echo     4DOS286.EXE, SHELL2E.COM, and SHELL2E.DOC stored on the registered disk.
      echo     These files will not be installed now.  Instead, they will be installed
      echo     when you are BRANDing your copy of 4DOS.
      echo.^bp^set reg5=Y
    endiff
  endiff
  echo.
  echo If you are installing 4DOS on a floppy disk system, you may change
  echo disks at any of the "(Y/N)" prompts during the copying process.
  echo.
  ask Install the system files in %sdir (Y/N)?
  if "%in" NE "Y" goto SKIPSYS
    set isys=Y^setdir %sdir 80K SKIPSYS
    %zn %sd:4dos 4dos.com keystack.sys
    iff "%_cpu"=="86" then^%zn %sd:4dos 4dos88.exe
    elseiff "%3"=="3" then^%zn %sd:4dos 4dos286.exe
    else %zn %sd:4dos 4dos88.exe
    endiff
:SKIPSYS
  ask Install the utility files in %udir (Y/N)?
  if "%in" NE "Y" goto SKIPUTIL
    set iutl=Y^setdir %udir 155K SKIPUTIL
    %zn %sd:4dos dos.hlp help.exe helpcfg.exe aliases
    %zn %sd:4dos 4dos.ico 4dosm.ico 4dos.pif
    if "%3"=="3" %zn %sd:4dos shell2e.com
:SKIPUTIL
  ask Install the 4DOS manual in %ddir (Y/N)?
  if "%in" NE "Y" goto SKIPMAN
    setdir %ddir 340K SKIPMAN
    %zn %sd:4dos 4dos.doc
:SKIPMAN
  ask Install the other documentation files in %ddir (Y/N)?
  if "%in" NE "Y" goto SKIPDOC
    setdir %ddir 175K SKIPDOC
    %zn %sd:4dos readme.doc update30.doc compat.doc
    %zn %sd:4dos order.frm support.bbs sysop.doc vendor.doc
    if "%3"=="3" %zn %sd:4dos shell2e.doc
:SKIPDOC
  echo.^pause Copying complete, press any key to return to menu ...
  goto MAINMENU
:NOT2
if "%msel" NE "3" goto NOT3
  dirchk^cdd %ddir^if exist *.doc goto VIEW
  if not exist *.doc error `No documentation files are available` MAINMENU
  :VIEW
  box 1 23
  puth 03 `               View / Print the Documentation Files`
  put  05 `INSTALL will now use the 4DOS SELECT command to display a`
  put  06 `list of the available documentation files.  If you installed`
  put  07 `the documentation files on a floppy disk be sure it is in the`
  put  08 `drive now.`
  put  10 `When you see the list of documentation files, use the up and`
  put  11 `down arrow keys to move between the files, and the space bar`
  put  12 `to toggle whether a file is selected.  When you are ready to`
  put  13 `view the selected files, press the Enter (ΔΩ) key.`
  put  15 `While viewing a file, press Esc to go on to the next file, or`
  put  16 `Ctrl-C to terminate file viewing.  Press "P" to print the file,`
  put  17 `"F" to search for a topic, and "N" to continue the search.  Be`
  put  18 `sure the printer is set up and the paper is aligned at the top`
  put  19 `of a page before you start printing.`
  keywait 21 MAINMENU
  select list [*.doc+*.frm]
  goto MAINMENU
:NOT3
if "%msel" NE "4" goto NOT4
  dirchk^cdd %sdir
  box 2 23
  puth 04 `                 Set up CONFIG.SYS Modifications`
  put  06 `INSTALL will now create a file called CONFIG.4D which will`
  put  07 `contain two lines to be placed in your CONFIG.SYS file in`
  put  08 `order to boot your system with 4DOS.  You must copy these`
  put  09 `lines to CONFIG.SYS yourself with an editor or any other`
  put  10 `method you choose.  INSTALL will not modify your CONFIG.SYS`
  put  11 `file.`
  put  13 `The CONFIG.4D file will be created in the directory you`
  put  14 `specified for your 4DOS system files, and will be displayed`
  put  15 `on screen after it has been created.`
  put  17 `If you already have a CONFIG.4D file, it will be deleted.`
  put  18 `If you don't want it deleted, use X at the prompt below to`
  put  19 `return to the main menu`
  keywait 21 MAINMENU
  set load=^if "%sdir"=="A:\" goto LOADOK^if "%sdir"=="C:\" goto LOADOK
  set load=/L:%sdir
:LOADOK
  echo DEVICE=%@upper[%_cwds]KEYSTACK.SYS >! config.4D
  echo SHELL=%@upper[%_cwds]4DOS.COM %load /p >>! config.4D
  cls^echo.^echo.^echo CONFIG.4D:^echo.^type config.4d^echo.
  pause Press any key to return to the main menu ...
  goto MAINMENU
:NOT4
if "%msel" NE "5" goto NOT5^if "%reg" NE "Y" goto NOT5
  dirchk^cdd %sdir^clr^box 1 23
  puth 03 `              BRAND a Registered Copy of 4DOS`
  put  05 `INSTALL will now allow you to brand your copy of 4DOS.  The`
  put  06 `branding procedure converts the shareware copy you just`
  put  07 `installed to a registered copy.  This method allows you to`
  put  08 `download later releases of 4DOS (e.g. a maintenance release,`
  put  09 `or your free upgrade) and brand them yourself, rather than`
  put  10 `having to obtain them on diskette from J.P. Software.`
  put  12 `If you do not have a registered copy of 4DOS, you cannot use`
  put  13 `this option.  Press X at the prompt below to return to the menu.`
  put  15 `Depending on your system configuration, INSTALL may only copy`
  put  16 `one of the 4DOS executable files (4DOS88.EXE or 4DOS286.EXE).`
  put  17 `The BRAND program will attempt to brand both files, and may`
  put  18 `therefore issue an error message indicating that it couldn't`
  put  19 `find one of the files.  You can ignore this message.`
  keywait 21 MAINMENU
:TRYBRAND
  cls^echo.^echo.^echo Record the serial number from the label on your registered 4DOS disk
  echo so that you can enter it when the BRAND program prompts you for it.
  echo.^echo If you are upgrading a copy of an earlier version of 4DOS, use the registered
  echo disk that came with that version.
:TRYBDISK
  set dname=registered^set dfile=brand.exe^set dskip=Y^gosub GETDISK
  if "%diskok"=="N" goto BRDONE^if "%diskok"=="W" goto TRYBDISK
  if "%reg5" NE "Y" goto DOBRAND
  if "%isys" NE "Y" goto REGUTL
  echo.^echo Installing 4DOS286 from registered disk to %sdir
  setdir %sdir 65K REGUTL
  %sd:pkunzip %sd:4dos2 4dos286.exe
:REGUTL
  if "%iutl" NE "Y" goto DOBRAND
  echo.^echo Installing SHELL2E from registered disk to %udir
  if not isdir %udir md %udir >& nul
  setdir %udir 6K DOBRAND
  %sd:pkunzip %sd:4dos2 shell2e.com shell2e.doc
:DOBRAND
  %sd:brand.exe^echo.
:BRDONE
  gosub SHRDISK^goto MAINMENU
:NOT5
if "%msel" NE "X" goto MAINMENU
:DONE
box 4 21
puth 06 `                   Installation Completed`
put  08 `Installation is complete.  In order to boot your system`
put  09 `with 4DOS, be sure to modify your CONFIG.SYS file to`
put  10 `include the lines created by INSTALL in CONFIG.4D.  You`
put  11 `may want to read the section of the manual on installation`
put  12 `options to see if you prefer options other than the defaults`
put  13 `set by INSTALL.`
put  15 `If you are upgrading from a previous version of 4DOS be sure`
put  16 `to read UPDATE30.DOC and the upgrade information in README.DOC`
put  17 `before using this new version.`
keywait2 19^clr^screen 23 0^quit
:UEXIT
clr2^screen 23 0 Exiting INSTALL per your requestrn^pause^quit

:GET_DIR
set olddir=%dir
:RETRY
setin %row 11 `                                                  `
if "%dir"=="" set dir=%olddir
eset dir^errclr^if "%@substr[%dir,1,1]"==":" goto DRVOK
error `The drive letter must be specified -- please try again` RETRY
:DRVOK
if isdir %dir return
md %dir >& nul^if isdir %dir return
error `Invalid directory -- please try again` RETRY

:SHRDISK
set dname=shareware^set dfile=4dos.zip^set dskip=N^gosub GETDISK
if "%diskok" NE "Y" goto SHRDISK^return

:GETDISK
set diskok=N^echo.^echo Place the %dname disk in drive %sd:
set dmsg=Press any key to continue
if "%dskip"=="Y" set dmsg=Press X to skip this step, or any other key to continue
bp^inkey %dmsg ... %%in^if "%dskip"=="Y" if "%in"=="X" return
if exist %sd:%dfile goto GOTDISK
beep 880 3^echo.^echo Wrong disk -- try again^set diskok=W^return
:GOTDISK
set diskok=Y^return

