'--------------------------------------------------------------------------
'	
'	Script Name:		install.mst
'
'	Script Purpose:		To install IntelliDraw 2.0.
'
'--------------------------------------------------------------------------
'
'	Developer:			Paul C. Anderson
'
'	Date Written:		10-01-93
'
'--------------------------------------------------------------------------
'
'	History of Change:
'
'		10-01-93	PCA		Initial design and code.
'
'--------------------------------------------------------------------------


'--------------------------------------------------------------------------
'
'INCLUDES
'
'--------------------------------------------------------------------------

'''$DEFINE DEBUG  ''Define for script development/debugging

'$INCLUDE 'setupapi.inc'
'$INCLUDE 'msdetect.inc'



'--------------------------------------------------------------------------
'
'CONSTANTS
'
'--------------------------------------------------------------------------

''Dialog ID's
CONST ASKQUIT       = 200
CONST DESTPATH      = 300
CONST ALDPATH       = 350
CONST EXITFAILURE   = 400
CONST EXITQUIT      = 600
CONST EXITSUCCESS   = 700
CONST APPHELP       = 900
CONST CHECK         = 2500
CONST CLIPART		= 2501
CONST ASKREGISTRATE	= 2502
CONST GETNAMEORG    = 7500
CONST BADOPTION     = 7900
CONST REG1          = 8000
CONST REG2          = 8100
CONST REG3          = 8200
CONST REG4          = 8300

''Dialog Numbers
CONST NAMEDIALOG	= 1
CONST APPDIALOG		= 2
CONST ALDUSDIALOG	= 3
CONST OPTIONSDIALOG	= 4
CONST CLIPARTDIALOG	= 5
CONST QUITDIALOG	= 6
CONST NOMOREDIALOGS	= 7

''Error Codes
CONST USERQUIT		= 32767
CONST NOWINDOWS		= 32766
CONST NOREGISTRATE	= 32765

CONST LOGO          = 1         ''Bitmap ID

CONST SW_MAXIMIZE   = 3

CONST APPFILES      = 1
CONST FILTERFILES   = 2

CONST RESTYPE%      = 10
CONST RESID%        = 1



'--------------------------------------------------------------------------
'
'GLOBALS
'
'--------------------------------------------------------------------------

GLOBAL CUIDLL$					''Custom user interface dll
GLOBAL HELPPROC$				''Help dialog procedure

GLOBAL DEST$                    ''Destination directory.
GLOBAL ALDDEST$                 ''Aldus directory.
GLOBAL WINDEST$					''Windows directory.
GLOBAL WININIFILE$				''Windows win.ini file.

GLOBAL USERNAME$                ''User name
GLOBAL USERORG$                 ''User organization
GLOBAL SERIAL$                  ''Product serial number

GLOBAL ALDUSEXISTS



'--------------------------------------------------------------------------
'
' PROTOTYPES
'
'--------------------------------------------------------------------------

DECLARE FUNCTION DoNotEnoughSpace% (totalNeededSpace&, availableFreeSpace&, drive$)
DECLARE FUNCTION DoQuit%(fromDialogNumber%)
DECLARE FUNCTION DoRegistration1%
DECLARE FUNCTION DoRegistration2%
DECLARE FUNCTION DoRegistration3%
DECLARE FUNCTION DoRegistration4%
DECLARE FUNCTION EmptyString (szString$) AS INTEGER
DECLARE FUNCTION GetAldusDir%
DECLARE FUNCTION GetApplicationDir%
DECLARE FUNCTION GetClipArt%
DECLARE FUNCTION GetFullSizeOnOption& (szSizeListName$, itemNumber%)
DECLARE FUNCTION GetNameAndPlace%
DECLARE FUNCTION GetOptions%
DECLARE FUNCTION GetSizeListFullSize& (szSizeListName$)
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE FUNCTION MakeSizeListAndReturnSize& (szNewListName$, szSectionName$)
DECLARE FUNCTION ProcessInstallChoices%


DECLARE SUB BadSuppliedPath
DECLARE SUB CreateRegistrationFile
DECLARE SUB InitializeCARES
DECLARE SUB InitializeIdrawInstall
DECLARE SUB InitializeSpaceSizes
DECLARE SUB InstallProgram
DECLARE SUB MakeKilobyteSizeSymbol (szSizeListName$, size&)
DECLARE SUB SetUpMenus
DECLARE SUB ShowWindow LIB "user" (hWnd%, wOpt%)



'--------------------------------------------------------------------------
'
' MAIN SECTION
'
'--------------------------------------------------------------------------

    i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal


	'---------------------------------
	' make sure the user has windows
	'---------------------------------

    WinDrive$ = MID$(GetWindowsDir, 1, 1)

    IF IsDriveValid(WinDrive$) = 0 THEN
		ERROR(NOWINDOWS)
	END IF


	'-----------------------------------
	' initialize and install the program
	'-----------------------------------

	InitializeIdrawInstall
	processDialogNumber% = NAMEDIALOG

	WHILE processDialogNumber% < NOMOREDIALOGS
		IF processDialogNumber% = NAMEDIALOG THEN
			processDialogNumber%	= GetNameAndPlace%
			fromDialogNumber%		= NAMEDIALOG
		END IF
		IF processDialogNumber% = APPDIALOG THEN
			processDialogNumber%	= GetApplicationDir%
			fromDialogNumber%		= APPDIALOG
		END IF
		IF processDialogNumber% = ALDUSDIALOG THEN
			processDialogNumber%	= GetAldusDir%
			fromDialogNumber%		= ALDUSDIALOG
		END IF
		IF processDialogNumber% = OPTIONSDIALOG THEN
			processDialogNumber%	= GetOptions%
			fromDialogNumber%		= OPTIONSDIALOG
		END IF
		IF processDialogNumber% = CLIPARTDIALOG THEN
			processDialogNumber%	= GetClipArt%
			fromDialogNumber%		= CLIPARTDIALOG
		END IF
		IF processDialogNumber% = QUITDIALOG THEN
			processDialogNumber%	= DoQuit%(fromDialogNumber%)
		END IF
	WEND

	IF processDialogNumber% <> NOMOREDIALOGS THEN	' user quit the install
		ERROR(USERQUIT)
	END IF

	InstallProgram

    sz$ = "REACTIVATE"
	WHILE sz$ = "REACTIVATE"
		sz$ = UIStartDlg(CUIDLL$, EXITSUCCESS, "FInfo0DlgProc", 0, "")
	WEND
	UIPop(1)


	'---------------------------------------
	' process computer generate registration
	'---------------------------------------

	sz$ = UIStartDlg(CUIDLL$, ASKREGISTRATE, "FInfo0DlgProc", 0, "")

	IF sz$ <> "CONTINUE" THEN	' user skips on-line reg
		UIPop(1)
		ERROR(NOREGISTRATE)
	END IF

	UIPop(1)

	InitializeCARES


	'-----------------------------------
	' process the dialogs until finished
	'-----------------------------------

	processDialogNumber%	= 1
	fromDialogNumber%		= 0

	WHILE processDialogNumber% < 6
		IF processDialogNumber% = 1 THEN
			processDialogNumber%	= DoRegistration1%
			fromDialogNumber%		= 1
		END IF
		IF processDialogNumber% = 2 THEN
			processDialogNumber%	= DoRegistration2%
			fromDialogNumber%		= 2
		END IF
		IF processDialogNumber% = 3 THEN
			processDialogNumber%	= DoRegistration3%
			fromDialogNumber%		= 3
		END IF
		IF processDialogNumber% = 4 THEN
			processDialogNumber%	= DoRegistration4%
			fromDialogNumber%		= 4
		END IF
	WEND

	IF processDialogNumber% <> 6 THEN	' user quit the install
		ERROR(NOREGISTRATE)
	END IF

	CreateRegistrationFile
	CreateProgmanItem "IntelliDraw 2.0", "PrintMe - Registration", "notepad.exe " + DEST$ + "\printme.txt", "", cmoOverwrite
    UIPopAll

END


	'----------------------------------------------
	' process any errors and quit the setup program
	'----------------------------------------------

QUIT:

	IF ERR = USERQUIT THEN
    	sz$ = "REACTIVATE"
		WHILE sz$ = "REACTIVATE"
			sz$ = UIStartDlg(CUIDLL$, EXITFAILURE, "FInfo0DlgProc", 0, "")
		WEND
    	UIPopAll
	ELSEIF ERR = NOWINDOWS THEN
		PRINT "The IntelliDraw application can only be installed"
		PRINT "on a system which has the Windows operating system"
	ELSEIF ERR = NOREGISTRATE THEN
		' do nothing
	ELSE
    	i% = DoMsgBox("Setup sources were corrupted, call 1-619-558-6000!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
	END IF
END







'========================================================================
'
'	SUBROUTINES
'
'========================================================================

'------------------------------------------------------------------------
'
'	CreateRegistrationFile
'
'		Create the registration file for printing and mailing
'
'------------------------------------------------------------------------
SUB CreateRegistrationFile STATIC

	'---------------------------------------------
	' create a file and open it for registration
	'---------------------------------------------

	theFile$ = DEST$ + "\PRINTME.TXT"
    OpenLogFile theFile$, 0


	'---------------------------------------------
	' write out the user name and address stuff
	'---------------------------------------------

    WriteToLogFile ""
    WriteToLogFile "User:               " + GetSymbolValue("NameOut")
    WriteToLogFile "Company:            " + GetSymbolValue("OrgOut")
    WriteToLogFile "Program:            IntelliDraw 2.0"
    WriteToLogFile "Serial Number:      " + SERIAL$
    WriteToLogFile "Address 1:          " + GetSymbolValue("Addr1Out")
    WriteToLogFile "Address 2:          " + GetSymbolValue("Addr2Out")
    WriteToLogFile "City:               " + GetSymbolValue("CityOut")
    WriteToLogFile "State/Province:     " + GetSymbolValue("StateOut")
    WriteToLogFile "Country:            " + GetSymbolValue("CounOut")
    WriteToLogFile "Telephone:          " + GetSymbolValue("TeleOut")
    WriteToLogFile "Zip/Postal code:    " + GetSymbolValue("ZipOut")
    WriteToLogFile "Fax:                " + GetSymbolValue("FaxOut")


	'---------------------------------------------
	' write out the ownership information
	'---------------------------------------------

	OWNERTYPE$ = GetSymbolValue("ButtonChecked")

    IF OWNERTYPE$ = "1" THEN
        WriteToLogFile "Owned by:           An Individual"
    ELSEIF OWNERTYPE$ = "2" THEN
        WriteToLogFile "Owned by:           A Business"
    ELSEIF OWNERTYPE$ = "3" THEN
        WriteToLogFile "Owned by:           A School"
    ELSE
        WriteToLogFile "Owned by:           A Government Office"
    ENDIF


    WriteToLogFile "Bought at:              " + GetSymbolValue("BuyMenuOut")
    WriteToLogFile "Heard about from        " + GetSymbolValue("AwareMenuOut")
    WriteToLogFile "Will use at:            " + GetSymbolValue("UseMenuOut")
    WriteToLogFile "Number of employees:    " + GetSymbolValue("EmpMenuOut")
    WriteToLogFile "Main business:          " + GetSymbolValue("BusMenuOut")
    WriteToLogFile "Job function:           " + GetSymbolValue("DepMenuOut")
    WriteToLogFile "Purchase influence:     " + GetSymbolValue("InfMenuOut")


	'---------------------------------------------
	' write out subscription material information
	'---------------------------------------------

    WriteToLogFile "Magazines read:"

    IF GetListItem("CheckMagsOut", 1) = "ON" THEN
        WriteToLogFile "                        MacUser"
    ENDIF
    IF GetListItem("CheckMagsOut", 2) = "ON" THEN
            WriteToLogFile "                    MacWorld"
    ENDIF
    IF GetListItem("CheckMagsOut", 3) = "ON" THEN
            WriteToLogFile "                    MacWEEK"
    ENDIF
    IF GetListItem("CheckMagsOut", 4) = "ON" THEN
            WriteToLogFile "                    PCWeek"
    ENDIF
    IF GetListItem("CheckMagsOut", 5) = "ON" THEN
            WriteToLogFile "                    PC Magazine"
    ENDIF
    IF GetListItem("CheckMagsOut", 6) = "ON" THEN
            WriteToLogFile "                    Windows Magazine"
    ENDIF
    IF GetListItem("CheckMagsOut", 7) = "ON" THEN
            WriteToLogFile "                    InfoWorld"
    ENDIF
    IF GetListItem("CheckMagsOut", 8) = "ON" THEN
            WriteToLogFile "                    PCWorld"
    ENDIF
    IF GetListItem("CheckMagsOut", 9) = "ON" THEN
            WriteToLogFile "                    User Group Newsletter"
    ENDIF
    IF EmptyString( OTHERMAG1$ ) > 0 THEN
        WriteToLogFile "                    " + GetSymbolValue("Other1Out")
    ENDIF
    IF EmptyString( OTHERMAG2$ ) > 0 THEN
        WriteToLogFile "                    " + GetSymbolValue("Other2Out")
    ENDIF
    IF EmptyString( OTHERMAG3$ ) > 0 THEN
        WriteToLogFile "                    " + GetSymbolValue("Other3Out")
    ENDIF


	'---------------------------------------------
	' write out computer information
	'---------------------------------------------

    WriteToLogFile "Computer Model:             " + GetSymbolValue("ListModelOut")
    WriteToLogFile "RAM:                        " + GetSymbolValue("ListRAMOut")
    WriteToLogFile "Processor type:             " + GetSymbolValue("ListProcessOut")

    IF GetSymbolValue("RadioBW") = "1" THEN
        WriteToLogFile "Printer:                    Black & White"
    ELSE
        WriteToLogFile "Printer:                    Color"
    ENDIF

    WriteToLogFile "Other equipment:"

    IF GetListItem( "CheckEquipOut", 1) = "ON" THEN
        WriteToLogFile "                            Gray-scale scanner"
    ENDIF
    IF GetListItem( "CheckEquipOut", 2) = "ON" THEN
        WriteToLogFile "                            Color scanner"
    ENDIF
    IF GetListItem( "CheckEquipOut", 3) = "ON" THEN
        WriteToLogFile "                            Film recorder"
    ENDIF
    IF GetListItem( "CheckEquipOut", 4) = "ON" THEN
        WriteToLogFile "                            24-bit video card"
    ENDIF
    IF GetListItem( "CheckEquipOut", 5) = "ON" THEN
        WriteToLogFile "                            Video capture device"
    ENDIF
    IF GetListItem( "CheckEquipOut", 6) = "ON" THEN
        WriteToLogFile "                            Desktop video card"
    ENDIF
    IF GetListItem( "CheckEquipOut", 7) = "ON" THEN
        WriteToLogFile "                            Pressure-sensitive tablet"
    ENDIF
    IF GetListItem( "CheckEquipOut", 8) = "ON" THEN
        WriteToLogFile "                            Non-pressure-sensitive tablet"
    ENDIF
    IF GetListItem( "CheckEquipOut", 9) = "ON" THEN
        WriteToLogFile "                            CD-ROM drive"
    ENDIF

    WriteToLogFile "Type of output device:"




	OTHEROUTPUT$	= GetSymbolValue( "OtherOutputOut" )
	PRINTERTYPE$	= GetSymbolValue( "RadioOutput" )

    IF PRINTERTYPE$ = "1" THEN
        WriteToLogFile "                            Dot matrix"
    ELSEIF PRINTERTYPE$ = "2" THEN
        WriteToLogFile "                            Ink jet"
    ELSEIF PRINTERTYPE$ = "3" THEN
        WriteToLogFile "                            Laser"
    ELSEIF PRINTERTYPE$ = "4" THEN
        WriteToLogFile "                            Imagesetter"
    ELSEIF PRINTERTYPE$ = "5" THEN
        WriteToLogFile "                            Plotter"
    ENDIF

    IF EmptyString( OTHEROUTPUT$ ) > 0 THEN
        WriteToLogFile "                            " + OTHEROUTPUT$
    ENDIF

    CloseLogFile

END SUB





'------------------------------------------------------------------------
'
'	DoNotEnoughSpace%
'
'		Do not enough space available processing
'
'------------------------------------------------------------------------
FUNCTION DoNotEnoughSpace%(totalNeededSpace&, availableFreeSpace&, drive$) STATIC

	moreSpace% = ((totalNeededSpace& - availableFreeSpace&) / 1000) + 1
	moreSpaceString$ = STR$(moreSpace%)
	i% = DoMsgBox("To install on drive " + drive$ + ", an additional " + moreSpaceString$ + " kilobytes of free space is needed.", "",  MB_OK + MB_ICONHAND + MB_TASKMODAL)
	DoNotEnoughSpace% = 7

END FUNCTION





'------------------------------------------------------------------------
'
'	DoQuit%
'
'		Process the quit command
'
'------------------------------------------------------------------------
FUNCTION DoQuit%(fromDialogNumber%) STATIC

	goToDialog% = 0

	sz$ = "REACTIVATE"
	WHILE sz$ = "REACTIVATE"
		sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
	WEND

	IF sz$ = "EXIT" THEN	' quit
        UIPopAll

	    sz$ = "REACTIVATE"
		WHILE sz$ = "REACTIVATE"
			sz$ = UIStartDlg(CUIDLL$, EXITQUIT, "FInfo0DlgProc", 0, "")
		WEND

		goToDialog% = NOMOREDIALOGS + 1
	ELSE	' return to the dialog that called quit
		goToDialog% = fromDialogNumber%
    END IF

	UIPop(1)
	DoQuit% = goToDialog%
						
END FUNCTION





'------------------------------------------------------------------------
'
'	DoRegistration1%
'
'		Gather registration information from screen 1.
'
'------------------------------------------------------------------------
FUNCTION DoRegistration1% STATIC

    sz$ = UIStartDlg(CUIDLL$, REG1, "FReg1DlgProc", APPHELP, HELPPROC$)

    IF sz$ = "CONTINUE" THEN
        SetSymbolValue "NameIn",		GetSymbolValue("NameOut")
        SetSymbolValue "OrgIn",			GetSymbolValue("OrgOut")
        SetSymbolValue "Addr1In",		GetSymbolValue("Addr1Out")
        SetSymbolValue "Addr2In",		GetSymbolValue("Addr2Out")
        SetSymbolValue "CityIn",		GetSymbolValue("CityOut")
        SetSymbolValue "CounIn",		GetSymbolValue("CounOut")
        SetSymbolValue "TeleIn",		GetSymbolValue("TeleOut")
        SetSymbolValue "StateIn",		GetSymbolValue("StateOut")
        SetSymbolValue "ZipIn",			GetSymbolValue("ZipOut")
        SetSymbolValue "FaxIn",			GetSymbolValue("FaxOut")
        SetSymbolValue "RadioDefault",	GetSymbolValue("ButtonChecked")

		goToDialog% = 2
    ELSEIF sz$ = "REACTIVATE" THEN
        goToDialog% = 1
    ELSEIF sz$ = "BACK" THEN
        goToDialog% = 1
    ELSE	' quitting
		goToDialog% = 7
    END IF

	UIPop(1)
	DoRegistration1% = goToDialog%

END FUNCTION



'------------------------------------------------------------------------
'
'	DoRegistration2%
'
'		Gather registration information from screen 2.
'
'------------------------------------------------------------------------
FUNCTION DoRegistration2% STATIC

    sz$ = UIStartDlg(CUIDLL$, REG2, "FListDlgProc", APPHELP, HELPPROC$)

    IF sz$ = "CONTINUE" THEN
		goToDialog% = 3
    ELSEIF sz$ = "REACTIVATE" THEN
		goToDialog% = 2
    ELSEIF sz$ = "BACK" THEN
		goToDialog% = 1
    ELSE	' quitting
		goToDialog% = 7
    END IF

	UIPop(1)
	DoRegistration2% = goToDialog%

END FUNCTION



'------------------------------------------------------------------------
'
'	DoRegistration3%
'
'		Gather registration information from screen 3.
'
'------------------------------------------------------------------------
FUNCTION DoRegistration3% STATIC

    sz$ = UIStartDlg(CUIDLL$, REG3, "FMagsDlgProc", APPHELP, HELPPROC$)

    IF sz$ = "CONTINUE" THEN
	    FOR i% = 1 TO 10 STEP 1
        	ReplaceListItem "CheckMagsIn", i%, GetListItem("CheckMagsOut", i%)
    	NEXT i%
		
        SetSymbolValue "Other1In", GetSymbolValue("Other1Out")
        SetSymbolValue "Other2In", GetSymbolValue("Other2Out")
        SetSymbolValue "Other3In", GetSymbolValue("Other3Out")

		goToDialog% = 4
    ELSEIF sz$ = "REACTIVATE" THEN
		goToDialog% = 3
    ELSEIF sz$ = "BACK" THEN
		goToDialog% = 2
    ELSE	' quitting
		goToDialog% = 7
    END IF

	UIPop(1)
	DoRegistration3% = goToDialog%

END FUNCTION



'------------------------------------------------------------------------
'
'	DoRegistration4%
'
'		Gather registration information from screen 4.
'
'------------------------------------------------------------------------
FUNCTION DoRegistration4% STATIC

    sz$ = UIStartDlg(CUIDLL$, REG4, "FConfigDlgProc", APPHELP, HELPPROC$)

    IF sz$ = "CONTINUE" THEN
        SetSymbolValue "OtherOutputIn",		GetSymbolValue("OtherOutputOut")
        SetSymbolValue "RadioBWDef",		GetSymbolValue("RadioBW")
        SetSymbolValue "RadioOutputDef",	GetSymbolValue("RadioOutput")

    	FOR i% = 1 TO 9 STEP 1
        	ReplaceListItem "CheckEquipIn", i%, GetListItem("CheckEquipOut", i%)
    	NEXT i%

        goToDialog% = 6
    ELSEIF sz$ = "REACTIVATE" THEN
        goToDialog% = 4
    ELSEIF sz$ = "BACK" THEN
        goToDialog% = 3
    ELSE	' quitting
		goToDialog% = 7
    END IF

	UIPop(1)
	DoRegistration4% = goToDialog%

END FUNCTION



'------------------------------------------------------------------------
'
'	EmptyString
'
'		Determines if a string is empty
'
'------------------------------------------------------------------------
FUNCTION EmptyString (szString$) STATIC AS INTEGER

    pos% = 0
    strlen% = LEN( szString$ )

    FOR i% = 1 TO strlen% STEP 1
        c$ = MID$( szString$, i%, 1 )
        IF (c$ <> " ") AND (c$ <> CHR$(9)) THEN
            pos% = i%
            i% = strlen%
        END IF
    NEXT i%

    EmptyString = pos%

END FUNCTION





'------------------------------------------------------------------------
'
'	GetAldusDir%
'
'		Obtain the Aldus directory path.
'
'------------------------------------------------------------------------
FUNCTION GetAldusDir% STATIC

	goToDialog% = 0

    SetSymbolValue "EditTextIn", ALDDEST$
    SetSymbolValue "EditFocus", "END"

    sz$ = UIStartDlg(CUIDLL$, ALDPATH, "FEditDlgProc", APPHELP, HELPPROC$)

    IF sz$ = "CONTINUE" THEN
        ALDDEST$ = GetSymbolValue("EditTextOut")

        IF IsDirWritable(DEST$) = 0 THEN
    		i% = DoMsgBox("The supplied directory is not valid, please enter another directory path.", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
			goToDialog% = ALDUSDIALOG
		ELSE
			goToDialog% = OPTIONSDIALOG
        END IF
    ELSEIF sz$ = "REACTIVATE" THEN
		goToDialog% = ALDUSDIALOG
    ELSEIF sz$ = "BACK" THEN
		goToDialog% = APPDIALOG
	ELSE	' quitting
		goToDialog% = QUITDIALOG
	END IF

	UIPop(1)
	GetAldusDir% = goToDialog%

END FUNCTION





'------------------------------------------------------------------------
'
'	GetApplicationDir%
'
'		Obtain the application directory path.
'
'------------------------------------------------------------------------
FUNCTION GetApplicationDir% STATIC

	goToDialog% = 0

    SetSymbolValue "EditTextIn", DEST$
    SetSymbolValue "EditFocus", "END"

    sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)

    IF sz$ = "CONTINUE" THEN
        DEST$ = GetSymbolValue("EditTextOut")

        IF IsDirWritable(DEST$) = 0 THEN
    		i% = DoMsgBox("The supplied directory is not valid, please enter another directory path.", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
			goToDialog% = APPDIALOG
		ELSE
			IF ALDUSEXISTS = 0 THEN
				goToDialog% = ALDUSDIALOG
			ELSE
				goToDialog% = OPTIONSDIALOG
			END IF
        END IF
    ELSEIF sz$ = "REACTIVATE" THEN
		goToDialog% = APPDIALOG
    ELSEIF sz$ = "BACK" THEN
		goToDialog% = NAMEDIALOG
	ELSE	' quitting
		goToDialog% = QUITDIALOG
	END IF

	UIPop(1)
	GetApplicationDir% = goToDialog%

END FUNCTION





'------------------------------------------------------------------------
'
'	GetClipArt%
'
'		Retrieve the desired partial clip art installation.
'
'------------------------------------------------------------------------
FUNCTION GetClipArt% STATIC

    sz$ = UIStartDlg(CUIDLL$, CLIPART, "FClipArtDlgProc", APPHELP, HELPPROC$)
	UIPop(1)

	GetClipArt% = OPTIONSDIALOG

END FUNCTION





'------------------------------------------------------------------------
'
'	GetFullSizeOnOption&
'
'		Retrieve the accumulated size from a list of sizes
'
'------------------------------------------------------------------------
FUNCTION GetFullSizeOnOption&(szSizeListName$, itemNumber%) STATIC

	IF GetListItem("ClipArtListIn", itemNumber%) = "ON" THEN
		GetFullSizeOnOption& = GetSizeListFullSize&(szSizeListName$)
	ELSE
		GetFullSizeOnOption& = 0
	END IF

END FUNCTION





'------------------------------------------------------------------------
'
'	GetNameAndPlace%
'
'		Obtain name and company information.
'
'------------------------------------------------------------------------
FUNCTION GetNameAndPlace% STATIC

	goToDialog% = 0

	SetSymbolValue "NameIn", USERNAME$
	SetSymbolValue "OrgIn", USERORG$

	sz$ = UIStartDlg(CUIDLL$, GETNAMEORG, "FNameOrgDlgProc", APPHELP, HELPPROC$)

	IF sz$ = "CONTINUE" THEN
		USERNAME$	= GetSymbolValue( "NameOut" )
		USERORG$	= GetSymbolValue( "OrgOut" )

		IF EmptyString(USERNAME$) = 0 THEN
    		i% = DoMsgBox("A name must be entered.", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
			goToDialog% = NAMEDIALOG 
		ELSE
			goToDialog% = APPDIALOG
		END IF
	ELSEIF sz$ = "REACTIVATE" THEN
		goToDialog% = NAMEDIALOG
	ELSEIF sz$ = "BACK" THEN
		goToDialog% = NAMEDIALOG
	ELSE	' quitting
		goToDialog% = QUITDIALOG
	END IF

	UIPop(1)
	GetNameAndPlace% = goToDialog%

END FUNCTION






'------------------------------------------------------------------------
'
'	GetOptions%
'
'		Obtain the installation options.
'
'------------------------------------------------------------------------
FUNCTION GetOptions% STATIC

	goToDialog% = 0


	'----------------------------------
	' initialize the dialog information
	'----------------------------------
 
    FOR i% = 1 TO 2 STEP 1
        ReplaceListItem "CheckItemsIn", i%, GetListItem("CheckItemsOut", i%)
    NEXT i%

    FOR i% = 1 TO 3 STEP 1
        ReplaceListItem "RadioItemsIn", i%, GetListItem("RadioItemsOut", i%)
    NEXT i%

	InitializeSpaceSizes

		
	'---------------
	' run the dialog
	'---------------

    sz$ = UIStartDlg(CUIDLL$, CHECK, "FInstOptsDlgProc", APPHELP, HELPPROC$)

    IF sz$ = "CONTINUE" THEN
		theReturnCode% = ProcessInstallChoices%
        
		IF theReturnCode% = 0 THEN		' no items selected to install
            sz$ = UIStartDlg(CUIDLL$, BADOPTION, "FInfo0DlgProc", APPHELP, HELPPROC$)
            UIPop(1)
			goToDialog% = OPTIONSDIALOG
		ELSEIF theReturnCode% = 7 THEN
			goToDialog% = OPTIONSDIALOG
		ELSE
			goToDialog% = NOMOREDIALOGS
        END IF
    ELSEIF sz$ = "REACTIVATE" THEN
		goToDialog% = OPTIONSDIALOG
    ELSEIF sz$ = "RADIO" THEN
		goToDialog% = CLIPARTDIALOG
    ELSEIF sz$ = "BACK" THEN
		IF ALDUSEXISTS = 0 THEN
			goToDialog% = ALDUSDIALOG
		ELSE
			goToDialog% = APPDIALOG
		END IF
	ELSE	' quitting
		goToDialog% = QUITDIALOG
	END IF

	UIPop(1)
	GetOptions% = goToDialog%

END FUNCTION





'------------------------------------------------------------------------
'
'	GetSizeListFullSize&
'
'		Retrieve the accumulated size from a list of sizes
'
'------------------------------------------------------------------------
FUNCTION GetSizeListFullSize&(szSizeListName$) STATIC

	accumulatedSpace&	= 0
	numberOfFiles%		= GetListLength(szSizeListName$)
					
	FOR j% = 1 TO numberOfFiles%
		accumulatedSpace& = accumulatedSpace& + VAL(GetListItem(szSizeListName$, j%))
	NEXT j%	

	GetSizeListFullSize& = accumulatedSpace&

END FUNCTION





'------------------------------------------------------------------------
'
'	InitializeCARES
'
'		To initialize the CARES	
'
'------------------------------------------------------------------------
SUB InitializeCARES STATIC

    SetSymbolValue "NameIn",		USERNAME$
    SetSymbolValue "OrgIn",			USERORG$
    SetSymbolValue "Addr1In",		""
    SetSymbolValue "Addr2In",		""
    SetSymbolValue "CityIn",		""
    SetSymbolValue "CounIn",		""
    SetSymbolValue "TeleIn",		""
    SetSymbolValue "StateIn",		""
	SetSymbolValue "ZipIn",			""
    SetSymbolValue "FaxIn",			""
    SetSymbolValue "RadioDefault",	"1"
    SetSymbolValue "BuyMenuOut",	""
    SetSymbolValue "AwareMenuOut",	""
    SetSymbolValue "UseMenuOut",	""
    SetSymbolValue "BusMenuOut",	""
    SetSymbolValue "EmpMenuOut",	""
    SetSymbolValue "DepMenuOut",	""
    SetSymbolValue "InfMenuOut",	""
    SetSymbolValue "BuyMenuOut",	""
    SetSymbolValue "AwareMenuOut",	""
    SetSymbolValue "UseMenuOut",	""
    SetSymbolValue "BusMenuOut",	""
    SetSymbolValue "EmpMenuOut",	""
    SetSymbolValue "DepMenuOut",	""
    SetSymbolValue "InfMenuOut",	""

    SetSymbolValue "Other1In",		""
    SetSymbolValue "Other2In",		""
    SetSymbolValue "Other3In",		""

    SetSymbolValue "OtherOutputIn",		""
    SetSymbolValue "RadioBWDef",		""
    SetSymbolValue "RadioBW",			""
    SetSymbolValue "RadioOutputDef",	""
    SetSymbolValue "RadioOutput",		""
    SetSymbolValue "ListModelOut",		""
    SetSymbolValue "ListRAMOut",		""
    SetSymbolValue "ListProcessOut",	""

    FOR i% = 1 TO 10 STEP 1
        AddListItem "CheckMagsIn", "OFF"
        AddListItem "CheckMagsOut", "OFF"
    NEXT i%

    FOR i% = 1 TO 9 STEP 1
        AddListItem "CheckEquipIn", "OFF"
        AddListItem "CheckEquipOut", "OFF"
    NEXT i%

	SetUpMenus

END SUB



'------------------------------------------------------------------------
'
'	InitializeIdrawInstall
'
'		To initialize the IntelliDraw installer
'
'------------------------------------------------------------------------
SUB InitializeIdrawInstall STATIC

	'----------------------------------------
	' set up the initial installer window
	'----------------------------------------

	ShowWindow HwndFrame(), SW_MAXIMIZE

    CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
    HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure

    SetBitmap CUIDLL$, LOGO
    SetTitle "Aldus IntelliDraw 2.0 Setup"

    
	'----------------------------------------
	' retrieve the installer information file
	'----------------------------------------

    szInf$ = GetSymbolValue("STF_SRCINFPATH")
    IF szInf$ = "" THEN
        szInf$ = GetSymbolValue("STF_CWDDIR") + "IDRAW20.INF"
    END IF

    ReadInfFile szInf$


	'----------------------------------------
	' set up check for windows existence
	'----------------------------------------

	WINDEST$ = "C:\WINDOWS                                "		' initialize with al long string to allocate enough string memory
	WINDEST$ = GetWindowsDir

	WININIFILE$ = WINDEST$ + "win.ini"


   	'------------------------------------------------------
	' initialize the aldus and program directories
	'------------------------------------------------------

    DEST$ = "C:\IDRAW20                                   "		' initialize with al long string to allocate enough string memory
    DEST$ = "C:\IDRAW20"

	ALDDEST$ = "C:\ALDUS                                  "		' initialize with al long string to allocate enough string memory		

    IF DoesIniKeyExist (WININIFILE$, "Aldus", "AldusDirectory") = 0 THEN
        ALDDEST$ = "C:\ALDUS"
    ELSE
        ALDDEST$	= GetIniKeyString(WININIFILE$, "Aldus", "AldusDirectory")
		ALDUSEXISTS	= 1
    END IF


 	'----------------------------------------
	' initialize global variables and symbols
	'----------------------------------------

    USERNAME$		= ""
    USERORG$		= ""
    SERIAL$			= "38-2000-008054122"

    
	'----------------------------------------
	' set defaults
	'----------------------------------------

    FOR i% = 1 TO 2 STEP 1
        AddListItem "CheckItemsIn", "ON"
        AddListItem "CheckItemsOut", "ON"
    NEXT i%

	AddListItem "RadioItemsIn", "ON"
	AddListItem "RadioItemsOut", "ON"

    FOR i% = 2 TO 3 STEP 1
        AddListItem "RadioItemsIn", "OFF"
        AddListItem "RadioItemsOut", "OFF"
    NEXT i%

    FOR i% = 1 TO 12 STEP 1
        AddListItem "ClipArtListIn", "OFF"
    NEXT i%

END SUB



'------------------------------------------------------------------------
'
'	InitializeSpaceSizes
'
'		To initialize the space requirements for each section.
'
'------------------------------------------------------------------------
SUB InitializeSpaceSizes STATIC

	'----------------------------------------------
	' compute application install space requirement
	'  and put it into the SpaceRequired list.
	'----------------------------------------------

	TotalAldusFilesSize&		= MakeSizeListAndReturnSize&("AldusFilesSizes", "Aldus")
	TotalApplicationFilesSize&	= MakeSizeListAndReturnSize&("ApplicationFilesSizes", "Application")
	TotalWindowsFilesSize&		= MakeSizeListAndReturnSize&("WindowsFilesSizes", "Windows")

	ApplicationInstallSize&		= TotalAldusFilesSize& + TotalApplicationFilesSize& + TotalWindowsFilesSize&

	MakeKilobyteSizeSymbol "SpaceRequired", ApplicationInstallSize&		' first entry


	'----------------------------------------------
	' compute filters install space requirement
	'  and put it into the SpaceRequired list.
	'----------------------------------------------

	TotalFilesSize& = MakeSizeListAndReturnSize&("FiltersFilesSizes", "Filters")
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' second entry


	'----------------------------------------------
	' compute clip art install space requirements
	'  and put them into the SpaceRequired list.
	'----------------------------------------------

	TotalFilesSize& = MakeSizeListAndReturnSize&("AccentsFilesSizes", "Accents")
	TotalArtSize&	= TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' third entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("BordersFilesSizes", "Borders")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' fourth entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("ComputersFilesSizes", "Computers")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' fifth entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("CoolArtFilesSizes", "CoolArt")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' sixth entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("DefaultsFilesSizes", "Defaults")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' seventh entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("MovingPartsFilesSizes", "MovingParts")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' eighth entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("PatternsFilesSizes", "Patterns")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' ninth entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("PresentationsFilesSizes", "Presentations")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' tenth entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("SmartFormsFilesSizes", "SmartForms")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' eleventh entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("SpacePlansFilesSizes", "SpacePlans")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' twelfth entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("SymbolsFilesSizes", "Symbols")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' thirteenth entry

	TotalFilesSize& = MakeSizeListAndReturnSize&("DrawingsFilesSizes", "Drawings")
	TotalArtSize&	= TotalArtSize& + TotalFilesSize&
	MakeKilobyteSizeSymbol "SpaceRequired", TotalFilesSize&		' fourteenth entry

	MakeKilobyteSizeSymbol "SpaceRequired", TotalArtSize&		' fifteenth entry

END SUB



'------------------------------------------------------------------------
'
'	InstallProgram
'
'		Builds the copy list and performs all installation operations.
'
'------------------------------------------------------------------------
SUB InstallProgram STATIC

	'----------------------------------------------------
	' retrieve the installer source directory
	'  and create the destination directories
	'----------------------------------------------------

    SrcDir$ = GetSymbolValue("STF_SRCDIR")

    CreateDir DEST$, cmoNone
    CreateDir ALDDEST$, cmoNone


	'----------------------------------------------------
	' create a log file and open it
	'----------------------------------------------------

    OpenLogFile MakePath(DEST$, "LOG.TXT"), 0

    WriteToLogFile ""
    WriteToLogFile "Destination directory: '" + DEST$ + "'"
    WriteToLogFile ""


	'----------------------------------------------------
	' add appropriate files to the destination copy list
	'----------------------------------------------------

    IF GetListItem("CheckItemsOut", APPFILES) = "ON" THEN
        AddSectionFilesToCopyList "Application", SrcDir$, DEST$
        AddSectionFilesToCopyList "Aldus", SrcDir$, ALDDEST$
        AddSectionFilesToCopyList "Windows", SrcDir$, WINDEST$
        WriteToLogFile "Loaded: 'Application'"
    END IF

    IF GetListItem("CheckItemsOut", FILTERFILES) = "ON" THEN
        AddSectionFilesToCopyList "Filters", SrcDir$, ALDDEST$
        WriteToLogFile "Loaded: 'Filters'"
    END IF

    IF GetListItem("RadioItemsOut", 1) = "ON" THEN
        AddSectionFilesToCopyList "Accents",		SrcDir$, DEST$
        AddSectionFilesToCopyList "Borders",		SrcDir$, DEST$
        AddSectionFilesToCopyList "Computers",		SrcDir$, DEST$
        AddSectionFilesToCopyList "CoolArt",		SrcDir$, DEST$
        AddSectionFilesToCopyList "Defaults",		SrcDir$, DEST$
        AddSectionFilesToCopyList "MovingParts",	SrcDir$, DEST$
        AddSectionFilesToCopyList "Patterns",		SrcDir$, DEST$
        AddSectionFilesToCopyList "Presentations",	SrcDir$, DEST$
        AddSectionFilesToCopyList "SmartForms",		SrcDir$, DEST$
        AddSectionFilesToCopyList "SpacePlans",		SrcDir$, DEST$
        AddSectionFilesToCopyList "Symbols",		SrcDir$, DEST$
        AddSectionFilesToCopyList "Drawings",		SrcDir$, DEST$
        WriteToLogFile "Loaded: 'All Clip Art'"
    END IF

    IF GetListItem("RadioItemsOut", 2) = "ON" THEN
		IF GetListItem("ClipArtListIn", 1) = "ON" THEN
        	AddSectionFilesToCopyList "Accents",		SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 2) = "ON" THEN
        	AddSectionFilesToCopyList "Borders",		SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 3) = "ON" THEN
        	AddSectionFilesToCopyList "Computers",		SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 4) = "ON" THEN
        	AddSectionFilesToCopyList "CoolArt",		SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 5) = "ON" THEN
        	AddSectionFilesToCopyList "Defaults",		SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 6) = "ON" THEN
        	AddSectionFilesToCopyList "MovingParts",	SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 7) = "ON" THEN
        	AddSectionFilesToCopyList "Patterns",		SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 8) = "ON" THEN
        	AddSectionFilesToCopyList "Presentations",	SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 9) = "ON" THEN
        	AddSectionFilesToCopyList "SmartForms",		SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 10) = "ON" THEN
        	AddSectionFilesToCopyList "SpacePlans",		SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 11) = "ON" THEN
        	AddSectionFilesToCopyList "Symbols",		SrcDir$, DEST$
		END IF
		IF GetListItem("ClipArtListIn", 12) = "ON" THEN
        	AddSectionFilesToCopyList "Drawings",		SrcDir$, DEST$
		END IF

        WriteToLogFile "Loaded: 'Selected Clip Art'"
    END IF

    WriteToLogFile ""


	'-------------------------------------------------------
	' copy the desired files to the appropriate destinations
	'-------------------------------------------------------

    CopyFilesInCopyList


	'------------------------------------------------------
	' take care of the win.ini housekeeping for the install
	'------------------------------------------------------

	IF DoesIniKeyExist(WININIFILE$, "embedding", "IntelliDraw") = 0 THEN
		CreateIniKeyValue WININIFILE$, "embedding", "IntelliDraw", "", cmoOverwrite
	END IF

	IF DoesIniKeyExist(WININIFILE$, "Aldus", "AldusDirectory") = 0 THEN
		CreateIniKeyValue WININIFILE$, "Aldus", "AldusDirectory", ALDDEST$, cmoOverwrite
	END IF
	
	IF DoesIniKeyExist(WININIFILE$, "Aldus", "IntelliDraw02LangDir") = 0 THEN
		CreateIniKeyValue WININIFILE$, "Aldus", "IntelliDraw02LangDir", "USENGLSH", cmoOverwrite
	END IF


	'-----------------------------------------------------------
	' take care of serialization, the dictionary problem
	'	and the program management group
	'-----------------------------------------------------------

    IF GetListItem("CheckItemsOut", APPFILES) = "ON" THEN
        WriteToLogFile "Serialized Application"
        WriteToLogFile ""

        RES$ = USERNAME$ + CHR$(0) + SERIAL$ + CHR$(0) + USERORG$ + CHR$(0)
        StampResource "Application", "Stamp", DEST$, RESTYPE%, RESID%, RES$, LEN( RES$ )


		IF EXISTS(ALDDEST$ + "\usenglsh\aldeng.bpx") THEN
			NAME ALDDEST$ + "\usenglsh\aldeng.bpx" AS ALDDEST$ + "\usenglsh\aldeng.Obp"
		END IF

		IF EXISTS(ALDDEST$ + "\usenglsh\aldeng.nfo") THEN
			NAME ALDDEST$ + "\usenglsh\aldeng.nfo" AS ALDDEST$ + "\usenglsh\aldeng.Onf"
		END IF

		IF EXISTS(ALDDEST$ + "\usenglsh\aldeng.udc") THEN
			NAME ALDDEST$ + "\usenglsh\aldeng.udc" AS ALDDEST$ + "\usenglsh\aldeng.Oud"
		END IF

		IF EXISTS(ALDDEST$ + "\usenglsh\aldeng00.vpx") THEN
			NAME ALDDEST$ + "\usenglsh\aldeng00.vpx" AS ALDDEST$ + "\usenglsh\aldeng00.Ovp"
		END IF

		IF EXISTS(ALDDEST$ + "\usenglsh\aldeng.msp") THEN
			NAME ALDDEST$ + "\usenglsh\aldeng.msp" AS ALDDEST$ + "\usenglsh\aldeng.Oms"
		END IF


		CreateProgmanGroup "IntelliDraw 2.0", "", cmoNone
		ShowProgmanGroup  "IntelliDraw 2.0", 1, cmoNone
		CreateProgmanItem "IntelliDraw 2.0", "IntelliDraw 2.0", DEST$ + "\IDRAW2.EXE", "", cmoOverwrite
		CreateProgmanItem "IntelliDraw 2.0", "Basic Templates", DEST$ + "\IDRAW2.EXE ABASICTP.IDW", DEST$ + "\IDRAW.EXE,1", cmoOverwrite

		CreateProgmanItem "IntelliDraw 2.0", "Install Log File", "notepad.exe "+ DEST$ + "\log.txt", "", cmoOverwrite
		CreateProgmanItem "IntelliDraw 2.0", "Read Me", "notepad.exe "+ DEST$ + "\README.txt", "", cmoOverwrite
		CreateProgmanItem "IntelliDraw 2.0", "Filters Read Me", "notepad.exe "+ DEST$ + "\FILTERS.txt", "", cmoOverwrite

		AddDos5Help "IDraw", "An intelligent Windows drawing package from Aldus.", cmoNone
    END IF

    CloseLogFile

END SUB



'------------------------------------------------------------------------
'
'	MakeKilobyteSizeSymbol
'
'		To create size list and add entries to it.
'
'------------------------------------------------------------------------
SUB MakeKilobyteSizeSymbol (szSizeListName$, size&) STATIC

	intSize%	= size& / 1000
	stringSize$	= STR$(intSize%)

	AddListItem szSizeListName$, stringSize$

END SUB



'------------------------------------------------------------------------
'
'	MakePath
'
'		Appends a file name to a directory path with needed backslash
'
'------------------------------------------------------------------------
FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING

    IF szDir$ = "" THEN
        MakePath = szFile$
    ELSEIF szFile$ = "" THEN
        MakePath = szDir$
    ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
        MakePath = szDir$ + szFile$
    ELSE
        MakePath = szDir$ + "\" + szFile$
    END IF

END FUNCTION



'------------------------------------------------------------------------
'
'	MakeSizeListAndReturnSize&
'
'		To create size list from install file sections
'
'------------------------------------------------------------------------
FUNCTION MakeSizeListAndReturnSize& (szNewListName$, szSectionName$) STATIC

	neededSectionSpace&	= 0

	MakeListFromSectionSize szNewListName$, szSectionName$
	numberOfFiles% = GetListLength(szNewListName$)
					
	FOR j% = 1 TO numberOfFiles%
		neededSectionSpace& = neededSectionSpace& + VAL(GetListItem(szNewListName$, j%))
	NEXT j%

	MakeSizeListAndReturnSize& = neededSectionSpace&

END FUNCTION



'------------------------------------------------------------------------
'
'	ProcessInstallChoices
'
'		Process the installation choices made by the user
'
'------------------------------------------------------------------------
FUNCTION ProcessInstallChoices% STATIC

	'--------------------------------------------------------
	' initialize the windows, aldus and application variables
	'--------------------------------------------------------
	
	spaceForWinDrive&	= 0
	spaceForAldDrive&	= 0
	spaceForAppDrive&	= 0
	choice%				= 0


	'--------------------------------------
	' process the user installation options
	'--------------------------------------

	IF GetListItem("CheckItemsOut", 1) = "ON" THEN		' install application
		choice% = 1
		spaceForAldDrive& = GetSizeListFullSize&("AldusFilesSizes")
		spaceForAppDrive& = GetSizeListFullSize&("ApplicationFilesSizes")
		spaceForWinDrive& = GetSizeListFullSize&("WindowsFilesSizes")
	END IF

	IF GetListItem("CheckItemsOut", 2) = "ON" THEN		' install filters
		choice% = 2
		spaceForAldDrive& = spaceForAldDrive& + GetSizeListFullSize&("FiltersFilesSizes")
	END IF

	IF GetListItem("RadioItemsOut", 1) = "ON" THEN		' install all clip art
		choice% = 3
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("AccentsFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("BordersFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("ComputersFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("CoolArtFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("DefaultsFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("MovingPartsFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("PatternsFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("PresentationsFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("SmartFormsFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("SpacePlansFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("SymbolsFilesSizes")
		spaceForAppDrive& = spaceForAppDrive& + GetSizeListFullSize&("DrawingsFilesSizes")
	END IF

	IF GetListItem("RadioItemsOut", 2) = "ON" THEN		' install some clip art
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("AccentsFilesSizes", 1)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("BordersFilesSizes", 2)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("ComputersFilesSizes", 3)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("CoolArtFilesSizes", 4)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("DefaultsFilesSizes", 5)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("MovingPartsFilesSizes", 6)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("PatternsFilesSizes", 7)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("PresentationsFilesSizes", 8)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("SmartFormsFilesSizes", 9)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("SpacePlansFilesSizes", 10)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("SymbolsFilesSizes", 11)
		spaceForAppDrive& = spaceForAppDrive& + GetFullSizeOnOption&("DrawingsFilesSizes", 12)
		IF spaceForAppDrive& > 0 THEN
			choice% = 4
		END IF
	END IF


	IF choice% > 0 THEN		' files have been chosen to install

		'-------------------------------------------------------
		' figure out if installs are on same or different drives
		'  and if the drives have enough space on them
		'-------------------------------------------------------

		appDrive$ = MID$(DEST$, 1, 1)
		aldDrive$ = MID$(ALDDEST$, 1, 1)
		winDrive$ = MID$(WINDEST$, 1, 1)


		IF appDrive$ = aldDrive$ AND aldDrive$ = winDrive$ THEN
			totalNeededSpace&	= spaceForAldDrive& + spaceForAppDrive& + spaceForWinDrive&
			availableFreeSpace&	= GetFreeSpaceForDrive(appDrive$) 

			IF totalNeededSpace& > availableFreeSpace& THEN
				choice% = DoNotEnoughSpace%(totalNeededSpace&, availableFreeSpace&, appDrive$)
			END IF
		ELSEIF appDrive$ = winDrive$ THEN
			totalNeededSpace&		= spaceForAppDrive& + spaceForWinDrive&
			availableAppFreeSpace&	= GetFreeSpaceForDrive(appDrive$) 
			availableAldFreeSpace&	= GetFreeSpaceForDrive(aldDrive$) 

			IF totalNeededSpace& > availableAppFreeSpace& THEN
				choice% = DoNotEnoughSpace%(totalNeededSpace&, availableAppFreeSpace&, appDrive$)
			ELSEIF spaceForAldDrive& > availableAldFreeSpace& THEN
				choice% = DoNotEnoughSpace%(spaceForAldDrive&, availableAldFreeSpace&, aldDrive$)
			END IF
		ELSEIF appDrive$ = aldDrive$ THEN
			totalNeededSpace&		= spaceForAppDrive& + spaceForAldDrive&
			availableAppFreeSpace&	= GetFreeSpaceForDrive(appDrive$) 
			availableWinFreeSpace&	= GetFreeSpaceForDrive(winDrive$) 

			IF totalNeededSpace& > availableAppFreeSpace& THEN
				choice% = DoNotEnoughSpace%(totalNeededSpace&, availableAppFreeSpace&, appDrive$)
			ELSEIF spaceForWinDrive& > availableWinFreeSpace& THEN
				choice% = DoNotEnoughSpace%(spaceForWinDrive&, availableWinFreeSpace&, winDrive$)
			END IF
		ELSEIF winDrive$ = aldDrive$ THEN
			totalNeededSpace&		= spaceForWinDrive& + spaceForAldDrive&
			availableWinFreeSpace&	= GetFreeSpaceForDrive(winDrive$) 
			availableAppFreeSpace&	= GetFreeSpaceForDrive(appDrive$) 

			IF totalNeededSpace& > availableWinFreeSpace& THEN
				choice% = DoNotEnoughSpace%(totalNeededSpace&, availableWinFreeSpace&, winDrive$)
			ELSEIF spaceForAppDrive& > availableAppFreeSpace& THEN
				choice% = DoNotEnoughSpace%(spaceForAppDrive&, availableAppFreeSpace&, appDrive$)
			END IF
		ELSE
			availableAppFreeSpace&	= GetFreeSpaceForDrive(appDrive$) 
			availableAldFreeSpace&	= GetFreeSpaceForDrive(aldDrive$) 
			availableWinFreeSpace&	= GetFreeSpaceForDrive(winDrive$) 

			IF spaceForWinDrive& > availableWinFreeSpace& THEN
				choice% = DoNotEnoughSpace%(spaceForWinDrive&, availableWinFreeSpace&, winDrive$)
			ELSEIF spaceForAppDrive& > availableAppFreeSpace& THEN
				choice% = DoNotEnoughSpace%(spaceForAppDrive&, availableAppFreeSpace&, appDrive$)
			ELSEIF spaceForAldDrive& > availableAldFreeSpace& THEN
				choice% = DoNotEnoughSpace%(spaceForAldDrive&, availableAldFreeSpace&, aldDrive$)
			END IF
		END IF
	END IF

	ProcessInstallChoices% = choice%

END FUNCTION



'------------------------------------------------------------------------
'
'	SetUpMenus
'
'		To initialize the menus
'
'------------------------------------------------------------------------
SUB SetUpMenus STATIC

	'----------------------------------------
	' set up the buy menu
	'----------------------------------------

    AddListItem "BuyMenuIn", "A. Retail Computer Store"
    AddListItem "BuyMenuIn", "B. Non-Aldus Direct Mail"
    AddListItem "BuyMenuIn", "C. Aldus Direct Mail"
    AddListItem "BuyMenuIn", "D. Mail order/Catalog"
    WHEREBOUGHT$ = "                                                    "

    
	'----------------------------------------
	' set up the aware menu
	'----------------------------------------

    AddListItem "AwareMenuIn", "A. Catalog"
    AddListItem "AwareMenuIn", "B. Advertisements"
    AddListItem "AwareMenuIn", "C. Reviews"
    AddListItem "AwareMenuIn", "D. Word of mouth"
    AddListItem "AwareMenuIn", "E. Brochures/Flyers"
    AddListItem "AwareMenuIn", "F. From Direct Mail"
    AddListItem "AwareMenuIn", "G. Saw at a store"
    AddListItem "AwareMenuIn", "H. User Group"
    AddListItem "AwareMenuIn", "I. Demo disk/Trial offer"
    AddListItem "AwareMenuIn", "J. Trade Show"
    HOWAWARE$ = "                                                       "

    
	'----------------------------------------
	' set up the use menu
	'----------------------------------------

    AddListItem "UseMenuIn", "A. Home/Home office"
    AddListItem "UseMenuIn", "B. Business location"
    AddListItem "UseMenuIn", "C. Government office"
    AddListItem "UseMenuIn", "D. School/College"
    HOWUSED$ = "                                                        "

    
	'----------------------------------------
	' set up the business menu
	'----------------------------------------

    AddListItem "BusMenuIn", "A. Advertising/PR/Marketing"
    AddListItem "BusMenuIn", "B. Business Training"
    AddListItem "BusMenuIn", "C. Consulting"
    AddListItem "BusMenuIn", "D. Financial Services"
    AddListItem "BusMenuIn", "E. Education/K-8"
    AddListItem "BusMenuIn", "F. Education/9-12"
    AddListItem "BusMenuIn", "G. Education/College or University"
    AddListItem "BusMenuIn", "H. Government"
    AddListItem "BusMenuIn", "I. Graphic Design"
    AddListItem "BusMenuIn", "J. Health/Medical Services"
    AddListItem "BusMenuIn", "K. Manufacturing"
    AddListItem "BusMenuIn", "L. Non-profit"
    AddListItem "BusMenuIn", "M. Printing/Publishing"
    AddListItem "BusMenuIn", "N. Professional Services"
    AddListItem "BusMenuIn", "O. Retail"
    AddListItem "BusMenuIn", "P. Transportation/Utilities"
    AddListItem "BusMenuIn", "Q. Wholesale/Distribution"
    WHATBUSINESS$ = "                                                 "

    
	'----------------------------------------
	' set up the employees menu
	'----------------------------------------

    AddListItem "EmpMenuIn", "A. 1"
    AddListItem "EmpMenuIn", "B. 2-5"
    AddListItem "EmpMenuIn", "C. 6-10"
    AddListItem "EmpMenuIn", "D. 11-25"
    AddListItem "EmpMenuIn", "E. 26-100"
    AddListItem "EmpMenuIn", "F. 101-1,000"
    AddListItem "EmpMenuIn", "G. Over 1,000"
    AddListItem "EmpMenuIn", "H. Does not apply"
    NUMEMPLOYEES$ = "                                                  "

    
	'----------------------------------------
	' set up the department menu
	'----------------------------------------

    AddListItem "DepMenuIn", "A. Accounting/Finance"
    AddListItem "DepMenuIn", "B. Administration/Management/Personnel"
    AddListItem "DepMenuIn", "C. Consulting"
    AddListItem "DepMenuIn", "D. Costumer Service"
    AddListItem "DepMenuIn", "E. DP/MIS/Computer Support"
    AddListItem "DepMenuIn", "F. Educator/Trainer"
    AddListItem "DepMenuIn", "G. Engineering"
    AddListItem "DepMenuIn", "H. Graphic design/Art"
    AddListItem "DepMenuIn", "I. Medical Personnel"
    AddListItem "DepMenuIn", "J. Military"
    AddListItem "DepMenuIn", "K. Owner/President"
    AddListItem "DepMenuIn", "L. Retired"
    AddListItem "DepMenuIn", "M. Sales/Marketing"
    AddListItem "DepMenuIn", "N. Student"
    WHATDEPARTMENT$ = "                                                 "

    
	'----------------------------------------
	' set up the influence menu
	'----------------------------------------

    AddListItem "InfMenuIn", "A. Price"
    AddListItem "InfMenuIn", "B. Unique features"
    AddListItem "InfMenuIn", "C. Used in class"
    AddListItem "InfMenuIn", "D. Aldus reputation"
    AddListItem "InfMenuIn", "E. Ease of use"
    AddListItem "InfMenuIn", "F. Templates/Clip art"
    AddListItem "InfMenuIn", "G. Printing cabability"
    WHATINFLUENCE$ = "                                                  "

    
	'----------------------------------------
	' set up the computer model menu
	'----------------------------------------

    AddListItem "ListModelIn", "A. ALR"
    AddListItem "ListModelIn", "B. Compaq"
    AddListItem "ListModelIn", "C. Compudyne"
    AddListItem "ListModelIn", "D. Dell"
    AddListItem "ListModelIn", "E. Gateway"
    AddListItem "ListModelIn", "F. Hewlett-Packard"
    AddListItem "ListModelIn", "G. Hyundai"
    AddListItem "ListModelIn", "H. IBM"
    AddListItem "ListModelIn", "I. NEC"
    AddListItem "ListModelIn", "J. Packard Bell"
    MODEL$ = "                                                          "

    
	'----------------------------------------
	' set up the memory menu
	'----------------------------------------

    AddListItem "ListRAMIn", "A. 2MB"
    AddListItem "ListRAMIn", "B. 4MB"
    AddListItem "ListRAMIn", "C. 5MB"
    AddListItem "ListRAMIn", "D. 6MB"
    AddListItem "ListRAMIn", "E. 8MB"
    AddListItem "ListRAMIn", "F. 16MB"
    RAM$ = "                                                            "

    
	'----------------------------------------
	' set up the processor menu
	'----------------------------------------

    AddListItem "ListProcessIn", "A. 386SX"
    AddListItem "ListProcessIn", "B. 386"
    AddListItem "ListProcessIn", "C. 486SX"
    AddListItem "ListProcessIn", "D. 486"
    AddListItem "ListProcessIn", "E. Pentium"
    PROCESSOR$ = "                                                      "

END SUB
