.KEY dest,help/s
.BRA {
.KET }

; :ts=3
; HDInstall - Install Professional Page onto a hard drive.
;
; Inputs:
;    dest   Directory to install PPage into
;    help   Print instructions
;

;
; Some preliminary setup.
;
ASSIGN PPageInstUtil: PPageUtil:    ; Hook we can use when disk has been removed
ASSIGN PPageInstOrig: ""            ; Save initial directory

; Make sure he's running WB 1.3!
; Under 1.3, the "1 gt 2" test fails; we proceed to "FAILAT 10".
; Under 1.2, however, the IF command itself dies, since GT is not defined; 
; execution is not suspended, and the ECHO and SKIP are seen.
FAILAT 21
IF >NIL: 1 gt 2
	ECHO "*NVersion 1.3 of the Amiga Workbench software *E[;1mmust*E[m be"
	ECHO "present before this installation can proceed.*N"
   SKIP wrapup
ENDIF
FAILAT 10

; Start with a fresh copy, to avoid any screwups
IF EXISTS RAM:PPageInstall
   DELETE RAM:PPageInstall/#? quiet
ELSE
   MAKEDIR RAM:PPageInstall
ENDIF


C:COPY                C:Copy                     RAM:PPageInstall
RAM:PPageInstall/Copy C:Assign                   RAM:PPageInstall
RAM:PPageInstall/Copy C:Echo                     RAM:PPageInstall
RAM:PPageInstall/Copy C:FailAt                   RAM:PPageInstall
RAM:PPageInstall/Copy C:If                       RAM:PPageInstall
RAM:PPageInstall/Copy C:Else                     RAM:PPageInstall
RAM:PPageInstall/Copy C:Endif                    RAM:PPageInstall
RAM:PPageInstall/Copy C:Makedir                  RAM:PPageInstall
RAM:PPageInstall/Copy C:Execute                  RAM:PPageInstall
CD ram:PPageInstall                 ; Search it without adding it to path

COPY PPageInstUtil:misc/DiskMount    RAM:PPageInstall
COPY PPageInstUtil:misc/InstUtil     RAM:PPageInstall
COPY PPageInstUtil:Misc/Install-Proc RAM:PPageInstall

Assign PPageInstPgm:                ; Make sure these start fresh, too.
Assign PPageInstCG:

;
; Make sure needed system assignments exist.
;
INSTUTIL isdir T:
IF WARN
   INSTUTIL isdir RAM:T
   IF WARN
      MAKEDIR ram:T
   ENDIF
   ASSIGN T: ram:T
ENDIF

INSTUTIL isdir ENV:
IF WARN
   INSTUTIL isdir RAM:ENV
   IF WARN
      MAKEDIR ram:ENV
   ENDIF
   ASSIGN ENV: ram:ENV
ENDIF


;
; HELP processing
;
IF "{help}" eq "HELP"
   SKIP showme
ENDIF

INSTUTIL ask -dy "Do you need instructions [Y/N]? Y"
IF WARN
   SKIP noshow
ENDIF

LAB showme
   EXECUTE RAM:PPageInstall/DiskMount Program PPage: PPageInstPgm:
   PPageInstPgm:showme PPageInstUtil:Misc/HELP-Install
LAB noshow


;
; Make sure that the destination exists, that its name is
; in a useable form (ie. that it ends with a '/' if it's a directory),
; and that the user in fact wants to install into it.
;
IF NOT EXISTS {dest$SYS:}
   ECHO "*N ********** Couldn't find Hard Disk drawer {dest$SYS:} **********"
   SKIP forhelp
ENDIF

INSTUTIL isdir {dest$SYS:}
IF WARN
   CD RAM:PPageInstall
   ECHO "*N ********** {dest$SYS:} is not a drawer! **********"
LAB forhelp
   ECHO "*N For help, type"
   ECHO "      EXECUTE PPageUtil:Misc/HDInstall help"
   ECHO "*N or double-click on the *"Help*" icon in this drawer*N"
   SKIP wrapup
ENDIF
CD RAM:PPageInstall

ECHO "*N Answering *"No*" to the following question will cancel"
ECHO " the installation.  Your hard drive will not be changed.*N"
INSTUTIL ask -dy "Install Professional Page onto {dest$SYS:} [Y/N]? Y"
IF warn
   ECHO " Installation aborted!*N"
   SKIP wrapup
ENDIF

ECHO >ram:PPageInstall/DestPath1 "{dest$SYS:}"
INSTUTIL <ram:PPageInstall/DestPath1 >ram:PPageInstall/DestPath2 fixdir


ECHO "*N*N ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*N"
ECHO " Begin installation of Professional Page onto {dest$SYS:}*N"

EXECUTE <ram:PPageInstall/DestPath2 >nil: ram:PPageInstall/Install-Proc ?

ECHO "*N*N --------------------------------------------------------------------"
ECHO "  Please add the following command to the file s:Startup-sequence:"
ECHO "*N        Execute s:PPage-1.3-Startup"

ECHO "*N --------------------------------------------------------------------"
ECHO "*N*N Installation of Professional Page complete."
ECHO "*N ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*N"

;
; Clean up after ourselves
; Can't depend on anything but PPageInstOrig: and PPageInstUtil:,
; since we can come here from right after their definition.
;
LAB wrapup

CD PPageInstOrig:
Assign PPageInstOrig:
Assign PPageInstPgm:
Assign PPageInstCG:
DELETE >NIL: RAM:PPageInstall all quiet

PPageInstUtil:Misc/InstUtil ask "Press RETURN."
Assign PPageInstUtil:
