//=============================================================================
//      Installation script for Quest 5.0 Demo
//=============================================================================
getpath %(cwd)
%(CurrentDisk) 1

//-----------------------------------------------------------------------------
//      Make sure the following matches the number of bytes stored in
//      all ZIP files being extracted for the demo.
//-----------------------------------------------------------------------------
%(DemoSize)      10619994  // 

%(ExitInstall) FALSE             // TRUE if we need to now exit the installation
%(InsertDisk) FALSE              // TRUE if we should now go to the InsertDisk
						    // subroutine (required because we cannot do a
						    // goto from within a begin/end sequence)

title "Quest 5.0 Demo Installation"
// statusbar on

//-----------------------------------------------------------------------------
//      Get path to Quest directory
//-----------------------------------------------------------------------------
%(demopath) c:\qstdemo
editbox c c
begin
	title "Quest 5.0 Demo Installation"
	text "Please enter the path where you wish"
    text " the Quest 5.0 demo installed."
	text ""
	string %(demopath) "Quest demo path:"
	text ""
end
ifstatus false
	goto Exit

//-----------------------------------------------------------------------------
//      Extract installation bitmaps. Show first one.
//-----------------------------------------------------------------------------
infobox l b
	text "Preparing Installation" c
setpath %(demopath)
fileextract %(source)\INSTALL.ZIP
background %(demopath)\INSTALL1.PCX

//-----------------------------------------------------------------------------
//      Determine total number of bytes to be installed for progress bar.
//-----------------------------------------------------------------------------
ProgressBar %(DemoSize) r b

//-----------------------------------------------------------------------------
//      Check for sufficient disk space.
//-----------------------------------------------------------------------------
setpath %(demopath)
available %(TotalMem)
ifstatus true
	goto SufficientSpace  
messagebox c c
begin
	title "Not enough space"
	text "You do not have space on the selected drive."
	text ""
	text "The Quest 5.0 demo requires"
    text "%(TotalMem) K bytes of disk space."
end
goto Exit
SufficientSpace:

//=============================================================================
//      Create directory, put up install message.
//=============================================================================
setpath %(demopath)
clearscreen
infobox l b
	text "Installing Quest Demo" c

//=============================================================================
//      DISK 1
//=============================================================================

fileextract %(source)\QDEMO1.ZIP
ifstatus false
	goto ExtractFailed

//=============================================================================
//      DISK 2
//=============================================================================

%(NextStep) DemoFile2
%(DiskNum) 2
%(KeyFile) QDEMO2.ZIP
goto InsertDisk
DemoFile2:
setpath %(demopath)
fileextract %(source)\QDEMO2.ZIP
ifstatus false
	goto ExtractFailed

//=============================================================================
//      DISK 3.
//=============================================================================

%(NextStep) DemoFile3
%(DiskNum) 3
%(KeyFile) QDEMO3.ZIP
goto InsertDisk
DemoFile3:
setpath %(demopath)
fileextract %(source)\QDEMO3.ZIP
ifstatus false
	goto ExtractFailed

//=============================================================================
//      Create Windows Program Manager group.
//=============================================================================
clearscreen
infobox l b
begin
	text "Performing Quest 5.0 setup." c
	text "Please wait..." c
end
%(statusline) "Creating Program Manager group for Quest Demo"
icon "Quest 5.0 Demo" "%(demopath)\qwindemo.exe" "Quest 5.0 Demo" "%(demopath)\qwindemo.exe"

SuccessMessage:
%(statusline) ""
clearscreen
messagebox c c
begin
	title "Quest 5.0 Demo Installation"
	text "Quest 5.0 Demo has been installed" c
end
goto Exit

//=============================================================================
//      Ask for the proper diskette.
//=============================================================================
InsertDisk:
%(InsertDisk) FALSE
fileexist %(source)\%(KeyFile)
ifstatus true
	goto FileWasFound
InsertDiskAgain:
clearscreen
editbox c c
begin
	title "Quest 5.0 Installation"
	text "Please insert disk #%(DiskNum)."
	text ""
	text "If the files from this disk can be found at"
	text "a different location, type a new path below."
	string %(source) ""
end
ifstatus false
	goto Exit
fileexist %(source)\%(KeyFile)
ifstatus false
	goto InsertDiskAgain

FileWasFound:
if %(CurrentDisk) = %(DiskNum)
	goto SkipBitmaps

%(CurrentDisk) %(DiskNum)
setpath %(demopath)

if %(CurrentDisk) = 2
	background "%(demopath)\install2.pcx"
if %(CurrentDisk) = 3
      background "%(demopath)\install3.pcx"

SkipBitmaps:
goto %(NextStep)

//=============================================================================
//      Error in extraction
//=============================================================================
ExtractFailed:
messagebox c c
begin
	title "Installation Failed"
	text "An error occurred during file extraction."
	text ""
	text "Check destination drive for disk space and"
	text "write access. If installation continues"
	text "to fail, call Allen Communication"
	text "technical support at (801) 537-1065."
end

//=============================================================================
//      Let's get out of here!
//=============================================================================
Exit:
setpath %(demopath)
filedelete install1.pcx
filedelete install2.pcx
filedelete install3.pcx
