;;============================================================================
;; System Checkout Procedures
;;============================================================================

;;----------------------------------------------------------------------------
;; CheckEnoughSystem
;;----------------------------------------------------------------------------


;; Procedure       CheckEnoughSystem

	;; <Esc> does nothing for duration of this (child) script

	LetButton <Esc> Do Nothing

	[InsufficientSystemAbort] := NoCharacter

	;;------------------
	;; Check system h/w
	;;------------------

	Do CheckWindows
	if [InsufficientSystemAbort] = YesCharacter
		goto SysReturn
	endif


	Do Check_DOS
	if [InsufficientSystemAbort] = YesCharacter
		goto SysReturn
	endif

	Do Check_Video
	if [InsufficientSystemAbort] = YesCharacter
		goto SysReturn
	endif

	Do Check_CPU
	if [InsufficientSystemAbort] = YesCharacter
		goto SysReturn
	endif

	Do Check_RAM
	if [InsufficientSystemAbort] = YesCharacter
		goto SysReturn
	endif

	Do Check_ExtendedMemory
	if [InsufficientSystemAbort] = YesCharacter
		goto SysReturn
	endif

	Do Check_MouseDriver
	if [InsufficientSystemAbort] = YesCharacter
		goto SysReturn
	endif


	;; This is as good a time/place as any to get this info:
	Do GetNumParallelPorts


:SysReturn
	Return

;; EndProcedure    ;; CheckEnoughSystem


;;----------------------------------------------------------------------------
;; SysAskContinue

Procedure	SysAskContinue

		Dialog [YesOrNo1] WhiteOnRed
			[ProductName] requires [String19],
			but this computer [String20].

			Do you wish to continue the installation anyway?
		EndDialog

		If [YesOrNo1] = YesCharacter
			[InsufficientSystemAbort] := NoCharacter
		else
			[InsufficientSystemAbort] := YesCharacter
		EndIf

EndProcedure		;; SysAskContinue


;;----------------------------------------------------------------------------
;; CheckWindows
;; 10/18/1993

Procedure	CheckWindows

	;; DON'T SWAP OUT - we don't yet know a drive to change to,
	;; and there's not enough space on the floppy to swap TO.
	;; This is a small program - let us pray.
	;;

	Run [InstallFromDirectory]\ChkOpEnv Quietly NoPrompt NoFrame

	;; Make sure it ran !

	If OSErrorCode <> 0

		ClearScreen

		if OSErrorCode = 8
			[String19] := Insufficient memory.
		else
			[String19] := ""	;; DOS error code was OSErrorCode.
		endif


		Dialog  PressAKey WhiteOnRed       ;; OS was unable to Run program
			Unable to run [InstallFromDirectory]\ChkOpEnv.EXE.
			[String19]

			Installation cannot proceed.
		EndDialog

		[InsufficientSystemAbort] := YesCharacter

		Return
	EndIf


	;; Now OsExitCode, the return code of ChkOpEnv,
	;; contains:
	;; 0  if DOS
	;; 1  if DOS Shell
	;; 2  if Win3.0 real mode
	;; 3  if Win3.0 standard mode
	;; 4  if Win3.0 enhanced mode
	;; 5  if Win3.1 standard mode
	;; 6  if Win3.1 standard mode
	;;
	;; We treat these as follows:
	;; 0,1  :  continue installation, it's OK
	;; 2,3,4:  fail installation - Win3.0
	;; 5,6:    fail installation - Win3.1

	if OSExitCode > 6		;; Unknown: ChkOpEnv bug.  "Can't happen".
		Exit
	endif

	if OSExitCode < 2		;; DOS or DOS Shell
		Exit
	endif


;;********************************************************
;; Dave:
;; Here be the dialog boxen for installation under Windows
;;********************************************************

	;;----------------------------
	;; It's Windows 3.x - fail
	;;----------------------------

	ClearScreen

	if OSExitCode < 5		;; 3.0

		Dialog PressAKey WhiteOnRed
			This is the DOS version of PeopleScheduler.
			Since you are running Windows, we encourage
			you to use the Windows version, which is
			included in the package you purchased.

			However, you are running Windows 3.0, so we
			also encourage you to upgrade to Windows 3.1,
			which PeopleScheduler requires.

			If you still want to install DOS, exit from 
			Windows and follow the DOS setup instructions.

		EndDialog

	else					;; 3.1

		Dialog PressAKey WhiteOnRed
			This is the DOS version of PeopleScheduler.
			Since you are running Windows, we encourage
			you to use the Windows version, which is
			included in the package you purchased.

			If you still want to install DOS, exit from 
			Windows and follow the DOS setup instructions.

		EndDialog

	endif


	[InsufficientSystemAbort] := YesCharacter


EndProcedure	;; CheckWindows

;;----------------------------------------------------------------------------
;; Check_DOS

Procedure	Check_DOS

	If OSVersion < [MinimumOSVersion]

		[SysSummary] := OSVersion

		[String19] := DOS 3.1 or higher
		[String20] := is running DOS [SysSummary]

		Do SysAskContinue

	EndIf


EndProcedure		;; Check_DOS

;;----------------------------------------------------------------------------
;; Check_Video
Procedure		Check_Video

	[InsufficientSystem] := NoCharacter

	If CGA
		[InsufficientSystem] := YesCharacter
		[SysSummary] := CGA
	EndIf

	If MDA
		[InsufficientSystem] := YesCharacter
		[SysSummary] := monochrome adapter
	EndIf

	If HGC
		[InsufficientSystem] := YesCharacter
		[SysSummary] := Hercules
	EndIf

	If HGCPlus
		[InsufficientSystem] := YesCharacter
		[SysSummary] := Hercules Graphics Plus
	EndIf

	If EGA
;;		[InsufficientSystem] := YesCharacter
		[SysSummary] := EGA
	EndIf


	If [InsufficientSystem] = YesCharacter

		[String19] := an EGA or better video adapter
		[String20] := is equipped with a [SysSummary]

		Do SysAskContinue

	EndIf


EndProcedure		;; Check_Video

;;----------------------------------------------------------------------------
;; Check_CPU
Procedure		Check_CPU

	If 808X
		[String19] := an 80286 or better CPU
		[String20] := has only an 8088 or 8086

		Do SysAskContinue
	EndIf


EndProcedure		;; Check_CPU

;;----------------------------------------------------------------------------
;; Check_RAM
Procedure		Check_RAM

	If MainMemory < [MinDOSMemRequiredK]

		[SysSummary] := MainMemory

		[String19] := at least [MinDOSMemRequiredK]K of RAM
		[String20] := has only [SysSummary]K

		Do SysAskContinue
	EndIf

EndProcedure		;; Check_RAM

;;----------------------------------------------------------------------------
;; Check_ExtendedMemory
Procedure		Check_ExtendedMemory

	If ExtendedMemoryPresent < [MinExtendedMemRequiredK]

		if ExtendedMemoryPresent = 0
			[SysSummary] := none
		else
			;; Number19: # megs; Number20: fraction of a meg

			[Number19] := ExtendedMemoryPresent / 1024
			[Number20] := [Number19] * 1024
			[Number20] := ExtendedMemoryPresent - [Number20]
			[Number20] := [Number20] * 100
			[Number20] := [Number19] / 1024

			[SysSummary] := only [Number19]

			if [Number20] = 0
			else
				[SysSummary] := [SysSummary].[Number20]
			endif

			[SysSummary] := [SysSummary] Meg

		endif


		[String19] := at least [MinExtendedMemRequiredMeg] Meg of extended memory
		[String20] := has [SysSummary]

		Do SysAskContinue

	EndIf


EndProcedure		;; Check_ExtendedMemory

;;----------------------------------------------------------------------------
;; Check_MouseDriver
Procedure		Check_MouseDriver

	If MouseDriverLoaded
	else

		Dialog [YesOrNo1] WhiteOnRed
			[ProductName] requires a mouse, and also requires
			that the mouse driver (usually named MOUSE.SYS or
			MOUSE.COM) be loaded by the operating system.

			However, no mouse driver is loaded.

			Do you wish to continue the installation anyway?
		EndDialog

		If [YesOrNo1] = YesCharacter
			[InsufficientSystemAbort] := NoCharacter
		else
			[InsufficientSystemAbort] := YesCharacter
		EndIf

	EndIf

EndProcedure		;; Check_MouseDriver


;;----------------------------------------------------------------------------
;; GetNumParallelPorts
;;----------------------------------------------------------------------------

Procedure       GetNumParallelPorts

	if PrinterPortPresent 2
		[NumParallelPorts] := 2
	else
		if PrinterPortPresent 1
			[NumParallelPorts] := 1
		else                                    ;; NO LPTx ports !
			[NumParallelPorts] := 0
		endif

		Exit
	endif

	if PrinterPortPresent 4
		[NumParallelPorts] := 4
	else
		if PrinterPortPresent 3
			[NumParallelPorts] := 3
		endif
	endif


EndProcedure	;; GetNumParallelPorts


;;----------------------------------------------------------------------------
;;----------------------------------------------------------------------------
;;----------------------------------------------------------------------------

