DefineVariables
Number [ReturnVal1]
Number [ReturnVal2]
Number [ReturnVal3]
Number [ReturnVal4]
Number [ReturnVal5]
Number [ErrCount]

Directory [WinDir]
Directory [WinsDir]

Logical [EnKeyb]
Logical [NetAvail]
Logical [MathPres]
Logical [CDAvail]

Number [XMSAvail]
Number [ExtmemPagesActive]
Number [ExtmemPagesAvail]
Number [ExtMemAvail]
Number [ExtMemPres]
Number [ExpMempgavail]
Number [ExpMempgactive]

Number [BitMapX]
Number [BitMapY]
Number [TextX]
Number [TextY]

Text [DispType]
Text [OSVer]
Text [DosVer]
Text [EmsVer]

Text [ProdExecutable]
Text [GroupTitle]
Text [GroupFile]
Text [ExistingGroupName]
Text [InstDir]

Text [FactsIconF]

Text [IconTitle]
Text [IconFile]

Text [ReadMeFile]      
Text [ReadMeTitle]

Text [Line1]
Text [Line2]

EndDefineVariables


Do SetupDisplay

Do CheckHardware

If [errcount] > 1
	Dialog UseHeader "Encountered Some Problems"
		.L The installation has encountered the following problems,
		.L you can continue to install or exit installation.
		[Array1][1]
		[Array1][2]
		[Array1][3]
		[Array1][4]
		[Array1][5]
		[Array1][6]
		[Array1][7]
	EndDialog
Endif

Delay 1000
Beep

:Start

DialogBox 150 100 UseHeader "Installing FreeHand 4.0" Returns [ReturnVal1] BlackOnLightGray
	Font "Helv" 8
	GroupBox @xy(5,4) 140 50 "Select Option"
	RadioButtonGroup Uses [ReturnVal2]
	   RadioButton @xy(10,20) 130 12 "&Install Everything     (11.4 MBytes)"
	   RadioButton @xy(10,35) 130 12 "&Custom Install"
	PushButton @xy(30,70) 40 14 "OK" 1
	PushButton @xy(80,70) 40 14 "&QUIT" 9
EndDialogBox

Incase [ReturnVal1] Is
	=1:
	=9: Do ByeBye
EndIncase

If [ReturnVal2] = 1
	Do FullInstall
	Goto Start
Endif

If [ReturnVal2] = 2
	Do CustomInstall
	Goto Start
Endif

If [ReturnVal2] = 0
	Dialog
		Click on one of the option buttons.
	EndDialog
	Goto Start
Endif


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Installation Setup Procedure
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Procedure SetupDisplay
SetDefaultBitMap Off	;; InstalIt's bitmap logo


[BitMapX]  := MaxX/2	;; Find Center of Screen
[BitMapY]  := MaxY/2

SetBackGroundColor 0 0 250 250 0 0
ShowWindow Maximized

SetPopupAttrTo YellowOnBlue
SetPopUpBorderTo none

SetBackGroundModeTo Transparent
SetScreenAttrTo WhiteOnGray

SetReplacementInquiry on
SetTopLineTo FreeHand 4.0 Installation

If FileIsInLibrary altsys.bmp
	If FIleExists ShadowDirectory\altsys.bmp
		DeleteFiles from ShadowDirectory Quietly
			altsys.bmp
		EndDeletefiles
	Endif

	QueFiles to ShadowDirectory noinquiry
		altsys.bmp
		altmsk.bmp
	EndQueFiles
	GetQuedFiles Quietly
	
EndIf
Delay 1000 
[TextX] := [BitMapX] - 100
[TextY] := [BitMapY] - 200
TextOut @xy([TextX],[TextY]) Welcome To FreeHand 4.0
Delay 2000

Delay 3000
ClearScreen
Delay 10

EndProcedure


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Full Installation Procedure
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Procedure FullInstall

QueFileGroup 1
QueFileGroup 2
QueFileGroup 3

[installationdirectory] := FH4

if WindowsNT
	DetermineInstallationDrive QueSize RequireFixed
Else
	DetermineInstallationDrive QueSize RequireFixed
Endif

DetermineInstallationDirectory installationdrive:\[installationdirectory]
GetQuedFiles

Do ModAutoexec
Do MakeGroup

EndProcedure


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Custom Installation Procedure
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Procedure CustomInstall

:StartCustom
DialogBox 160 120 UseHeader "Customizing FreeHand 4.0" Returns [ReturnVal1] BlackOnLightGray
	Font "Helv" 8
	GroupBox @xy(5,4) 145 70 "Select Options"
	CheckBox @xy(10,20) 130 12 "&FreeHand 4.0               (7.0 MBytes)" Uses [ReturnVal3]
	CheckBox @xy(10,35) 130 12 "&Printer description files  (2.2 Mbytes)" Uses [ReturnVal4]
	CheckBox @xy(10,50) 130 12 "&Sample Illustrations       (2.2 Mbytes)" Uses [ReturnVal5]
	PushButton @xy(35,85) 40 14 "OK" OK
	PushButton @xy(85,85) 40 14 "&Back" 9
EndDialogBox

Incase [ReturnVal1] Is
=1:
=9: Goto Start
EndIncase

If ([ReturnVal3] = 0) .and. ([ReturnVal4] = 0) .and. ([ReturnVal5] = 0)
	Dialog
		At least one option must be selected 
		or click Back to return to the previous screen.
	EndDialog
	Goto StartCustom
Endif

[installationdirectory] := FH4

If [ReturnVal3] = 1
	QueFileGroup 1
EndIf
If [ReturnVal4] = 1
	QueFileGroup 2
EndIf
If [ReturnVal5] = 1
	QueFileGroup 3
EndIf

if WindowsNT
	DetermineInstallationDrive QueSize RequireFixed
Else
	DetermineInstallationDrive QueSize RequireFixed
Endif

DetermineInstallationDirectory installationdrive:\[installationdirectory]

GetQuedFiles

;; Update autoexec.bat & group files if app is installed.
If [ReturnVal3] = 1
	Do ModAutoexec
	Do MakeGroup
EndIf

EndProcedure


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Autoexec.bat Modify Procedure
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Procedure ModAutoexec

ModifyAutoexecBat
	AddPathComponent [installationdirectory] At Beginning
EndModifyAutoexecBat

EndProcedure


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Program Group Procedure
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Procedure MakeGroup

ChangeDirectoryto [InstallationDirectory]
[ProdExecutable]  := [InstallationDirectory]\fh4.exe
[GroupTitle]      := FreeHand
[InstDir]         := [InstallationDirectory]
[IconFile]        := fh4.exe
[IconTitle]       := FreeHand 4.0
[ReadMeFile]      := [InstallationDirectory]\readme.txt
[ReadMeTitle]     := ReadMe FreeHand 4.0

ProgramManagerDDE
	CreateGroup([GroupTitle],[WindowsDirectory]\[GroupTitle].grp)
	AddItem([ProdExecutable],[IconTitle],[InstallationDirectory]\[IconFile])
	AddItem([ReadMeFile],[ReadMeTitle])
EndProgramManagerDDE


EndProcedure


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Hardware Check Procedure
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Procedure CheckHardware
[Number3] := 1

[Windir] := [WindowsDirectory]
[Winsdir] := [WindowsSystemDirectory]
[ExtmemPagesActive] := ExtendedMemoryPagesActive
[ExtmemPagesAvail] := ExtendedMemoryPagesAvailable
[ExtMemAvail] := ExtendedMemoryAvailable
[ExtMemPres] := ExtendedMemoryPresent
[ExpMempgAvail] := ExpandedMemoryPagesAvailable
[ExpMempgActive] := ExpandedMemoryPagesActive
[OsVer] := OSVersion
[DosVer] := DOSVersion
[EmsVer] := EMSVersion

[Errcount] := [Number3]

EndProcedure


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Installation Exit Procedure
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Procedure ByeBye

Delay 1000
SetBackGroundModeTo Transparent
SetScreenAttrTo WhiteOnGray

Delay 100
ClearScreen
Delay 100
SoLong

EndProcedure

EndScript