'**************************************************************************
'*                       MSSetup Toolkit PixFolio
'**************************************************************************
''  Revised Pixfolio Setup Script
''   Feb 94: David H. Goeb
''   Apr 94: David H. Goeb

''   Additions
''     Changed to have PCD files as part of application files
''     Added a WIN.INI check function to see if catalog was 
''      already installed, and also check if new version.
''      All Aztech Text files are also added to the program group
''      Further Enhancements are custom Install call and Multi
''      Catalog support
''     Additional bug fixes and addition of gems catalog


''$DEFINE DEBUG  ''Define for script development/debugging

'$INCLUDE 'setupapi.inc'
'$INCLUDE 'msdetect.inc'
'$INCLUDE 'mscuistf.inc'

''Dialog ID's
CONST WELCOME       = 100
CONST ASKQUIT       = 200
CONST DESTPATH      = 300
CONST EXITFAILURE   = 400
CONST EXITQUIT      = 600
CONST EXITSUCCESS   = 700
CONST EXITREGISTERED= 750
CONST OPTIONS       = 800
CONST APPHELP       = 900
CONST CUSTHELP      = 910
CONST REGHELP       = 920
CONST CUSTINST      = 6200
CONST TOOBIG        = 6300
CONST NOAVI         = 6350
CONST NOAPP         = 6360
CONST BADPATH       = 6400
CONST CDGETNAMEORG  = 7500
CONST MODELESS      = 5000
CONST QUITWIN       = 6500

''Bitmap ID
CONST LOGO = 1

''File Types
CONST APPFILES     = 1
CONST OPTFILES1    = 2
CONST OPTFILES2    = 3
CONST OPTFILES3    = 4
CONST SYMFILES     = 5
CONST CATFILES     = 6
''================================
GLOBAL CATCOST%

GLOBAL CC$

GLOBAL DEST$        ''Default destination directory.
GLOBAL WINDRIVE$    ''Windows drive letter.
GLOBAL OPTCUR$      ''Option selection from option dialog.
GLOBAL CUIDLL$      ''Custom user interface DLL
GLOBAL szTempDir$   ''Working directory
GLOBAL SysDir$      ''Windows System Directory
GLOBAL ini$         ''INI file path
GLOBAL astr$        ''Usefull little string

GLOBAL NOPT$     ''Option selection from OptFiles1 option dialog.

GLOBAL OPT1OPT$     ''?? Option selection from OptFiles1 option dialog.
GLOBAL OPT2OPT$     ''?? Option selection from OptFiles2 option dialog.
GLOBAL OPT3OPT$
GLOBAL SYMOPT$      ''Option selection for symbol files.

''CustInst list symbol names
GLOBAL APPNEEDS$    ''Option list costs per drive
GLOBAL OPT1NEEDS$
GLOBAL OPT2NEEDS$
GLOBAL OPT3NEEDS$   ''Multimedia files
GLOBAL SYMNEEDS$
GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)

''Dialog list symbol names
GLOBAL CHECKSTATES$
GLOBAL STATUSTEXT$
GLOBAL DRIVETEXT$


DECLARE SUB AddOptFilesToCopyList (ftype%)
DECLARE SUB RecalcOptFiles (ftype%)
DECLARE SUB RecalcPath
DECLARE SUB SetDriveStatus
DECLARE SUB Install
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING


INIT:
    CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
    HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure

    SetBitmap CUIDLL$, LOGO
	SetTitle "PixFolio Setup"
	szTempDir$ = GetSymbolValue("STF_CWDDIR")
    szInf$ = GetSymbolValue("STF_SRCINFPATH")
    IF szInf$ = "" THEN
       szInf$ = GetSymbolValue("STF_CWDDIR") + "PIXSETUP.INF"
    END IF
    ReadInfFile szInf$
	'' Force Catalog to be include unless selected off

	NOPT$ = "1"

	WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
''    DEST$ = WINDRIVE$ + ":\PIXFOLIO"
	DEST$ = ".............................................................................................................................."
	GetPixDir DEST$
	if DEST$ = "" THEN
		DEST$ = WINDRIVE$ + ":\PIXFOLIO"
	END IF
	ini$ = MakePath(GetWindowsDir, "WIN.INI")

	''CustInst list symbols
	CHECKSTATES$ = "CheckItemsState"
	STATUSTEXT$  = "StatusItemsText"
	DRIVETEXT$   = "DriveStatusText"
'   FOR i% = 1 TO 3 STEP 1
		AddListItem CHECKSTATES$, "ON"  '' Main program files
		AddListItem CHECKSTATES$, "ON"  '' PCD files
		AddListItem CHECKSTATES$, "OFF" '' VFW
		AddListItem CHECKSTATES$, "ON" '' Multimedia
		AddListItem CHECKSTATES$, "OFF" '' Symbols
'    NEXT i%
	FOR i% = 1 TO 5 STEP 1
		AddListItem STATUSTEXT$, ""
	NEXT i%
	FOR i% = 1 TO 7 STEP 1
		AddListItem DRIVETEXT$, ""
	NEXT i%
	ReplaceListItem DRIVETEXT$, 7, DEST$

	''Disk cost list symbols
	APPNEEDS$   = "AppNeeds"
	OPT1NEEDS$  = "Opt1Needs"
	OPT2NEEDS$  = "Opt2Needs"
	OPT3NEEDS$  = "Opt3Needs"
	SYMNEEDS$   = "SymNeeds"
	EXTRACOSTS$ = "ExtraCosts"
	BIGLIST$    = "BigList"
	FOR i% = 1 TO 5 STEP 1
		AddListItem BIGLIST$, ""
	NEXT i%
	FOR i% = 1 TO 26 STEP 1
		AddListItem EXTRACOSTS$, "0"
	NEXT i%

	''File Option Variables
	OPT1OPT$ = "1"
	OPT2OPT$ = "1"
	OPT3OPT$ = "1"
	SYMOPT$  = "1"

	SysDir$ = GetWindowsSysDir()
	RecalcPath
''    i% = DoMsgBox("RecalcPath OK", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
	SetDriveStatus
''    i% = DoMsgBox("SetDriveStatus OK", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)


     OPTCUR$ = "1"
'    DEST$ = "C:\PIXFOLIO"

'$IFDEF DEBUG
    i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
    WinDrive$ = MID$(GetWindowsDir, 1, 1)
    IF IsDriveValid(WinDrive$) = 0 THEN
	i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
	GOTO QUIT
    END IF
'$ENDIF ''DEBUG


WELCOME:
    sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
    IF sz$ = "CONTINUE" THEN
	UIPop 1
    ELSE
	GOSUB ASKQUIT
	GOTO WELCOME
    END IF


OPTION:
    SetSymbolValue "RadioDefault", OPTCUR$
OPTL1:

    NOPT$ = "0"
    sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
    OPTCUR$ = GetSymbolValue("ButtonChecked")

'$IFDEF DEBUG
     i% = DoMsgBox("Result ('"+OPTCUR$+"') Was Returned.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
'$ENDIF ''DEBUG

    IF OPTCUR$ = "1" THEN
      NOPT$ = "0"
    ELSE
      NOPT$ = "1"
    END IF

    IF sz$ = "CONTINUE" THEN
	UIPop(1)
    ELSEIF sz$ = "REACTIVATE" THEN
	GOTO OPTL1
    ELSE
	GOSUB ASKQUIT
	GOTO OPTION
    END IF


CUSTINST:
	SetDriveStatus
	sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", CUSTHELP, HELPPROC$)

	IF sz$ = "CONTINUE" THEN
		''Install only if it will fit.
		FOR i% = 1 TO 5 STEP 1
			IF GetListItem(BIGLIST$, i%) <> "" THEN
				GOSUB TOOBIG
				GOTO CUSTINST
			END IF
		NEXT i%
		UIPop 1
		GOTO INSTALLIT
	ELSEIF sz$ = "PATH" THEN
		GOTO GETPATH
	ELSEIF sz$ = "CHK1" THEN
		IF DoesFileExist(MakePath(DEST$, "PIXFOLIO.EXE"), femReadWrite) = 0 AND GetListItem(CHECKSTATES$, APPFILES) = "OFF" THEN
			GOSUB NOAPP
			GOTO CUSTINST
		END IF
		RecalcOptFiles APPFILES
		RecalcOptFiles SYMFILES
		SetDriveStatus
		GOTO CUSTINST
	ELSEIF sz$ = "CHK2" THEN
		RecalcOptFiles OPTFILES1
		RecalcOptFiles SYMFILES
		SetDriveStatus
		GOTO CUSTINST
	ELSEIF sz$ = "CHK3" THEN
		IF GetListItem(CHECKSTATES$, OPTFILES2) = "ON" THEN
			IF CheckForAVI = 0 THEN
				GOSUB NOAVI
				ReplaceListItem CHECKSTATES$, OPTFILES2, "OFF"
			END IF
		END IF
		RecalcOptFiles OPTFILES2
		RecalcOptFiles SYMFILES
		SetDriveStatus
		GOTO CUSTINST
	ELSEIF sz$ = "CHK4" THEN
		RecalcOptFiles OPTFILES3
		RecalcOptFiles SYMFILES
		SetDriveStatus
		GOTO CUSTINST
	ELSEIF sz$ = "CHK5" THEN
		RecalcOptFiles SYMFILES
		SetDriveStatus
		GOTO CUSTINST

	ELSEIF sz$ = "BTN2" THEN
		GOTO OPTFILES1
	ELSEIF sz$ = "BTN3" THEN
		GOTO OPTFILES2
	ELSEIF sz$ = "BTN4" THEN
		GOTO OPTFILES3
	ELSEIF sz$ = "BTN5" THEN
		GOTO SYMFILES
	ELSEIF sz$ = "REACTIVATE" THEN
		RecalcPath
		SetDriveStatus
		GOTO CUSTINST
	ELSE
		GOTO OPTION
		'' Allow to reverse back to change CD option
		''GOSUB ASKQUIT
		''GOTO CUSTINST
	END IF


GETPATH:
	SetSymbolValue "EditTextIn", DEST$
	SetSymbolValue "EditFocus", "END"
GETPATHL1:
	sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)

	IF sz$ = "CONTINUE" THEN
		olddest$ = DEST$
		DEST$ = GetSymbolValue("EditTextOut")

		''Validate new path.
		IF IsDirWritable(DEST$) = 0 THEN
			GOSUB BADPATH
			GOTO GETPATHL1
		END IF
		UIPop 1

		''Truncate display if too long.
		IF LEN(DEST$) > 23 THEN
			ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
		ELSE
			ReplaceListItem DRIVETEXT$, 7, DEST$
		END IF

		''Recalc if path changed.
		IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
			RecalcPath
			SetDriveStatus
		END IF

		olddest$ = ""
		GOTO CUSTINST
	ELSEIF sz$ = "REACTIVATE" THEN
		RecalcPath
		SetDriveStatus
		GOTO GETPATHL1
	ELSEIF sz$ = "EXIT" THEN
		GOSUB ASKQUIT
		GOTO GETPATHL1
	ELSE
		UIPop 1
		GOTO CUSTINST
	END IF

INSTALLIT:
	SetSymbolValue "SERIAL", "2X09AA001302"
	SetSymbolValue "OWNER", "Aztech New Media Corp."
	IF DoesFileExist(MakePath(DEST$, "PIXFOLIO.EXE"), femReadWrite) = 1 THEN
		l& = GetStringTable(DEST$)
		IF DoesFileExist(MakePath(DEST$, "PIXFOLIO.INI"), femReadWrite) = 1 THEN
			ini$ = MakePath(DEST$, "PIXFOLIO.INI")
		END IF
	END IF
	SERIAL$ = GetSymbolValue("SERIAL")
	OWNER$  = GetSymbolValue("OWNER")
	SERIAL1$ = GetIniKeyString(ini$, "PixFolio", "Registration Nbr")
	OWNER1$ = GetIniKeyString(ini$, "PixFolio", "Registered To")
'*    i% = DoMsgBox(SERIAL$+" "+SERIAL1, "Serial Number", MB_OK)

	IF ValidateReg(SERIAL1$) = 1 THEN
		SERIAL$ = SERIAL1$
		OWNER$ = OWNER1$
'*        i% = DoMsgBox(SERIAL$+" "+SERIAL1, "Serial Number", MB_OK)
	END IF
	SetSymbolValue "SERIAL", SERIAL$
	SetSymbolValue "OWNER", OWNER$

	Install

	IF(DoesFileExist(MakePath(DEST$, "PIXPCD.DLL"), femReadWrite) = 1 OR DoesFileExist(MakePath(DEST$, "PIXAVI.DLL"), femReadWrite) = 1) AND MID$(SERIAL$, 6, 1) <> "B" THEN
		GOTO GETSERIAL
	END IF

	IF ValidateReg(SERIAL$) = 1 THEN
		GOTO UPDATEIT
	END IF

GETSERIAL:

	sz$ = UIStartDlg(CUIDLL$, CDGETNAMEORG, "FNameOrgDlgProc", REGHELP, HELPPROC$)
    DEST$ = GetSymbolValue("EditTextOut")

    IF sz$ = "CONTINUE" THEN
		UIPop 1
	ELSEIF sz$ = "CANCEL" THEN
		UIPop 1
    ELSE
		GOSUB ASKQUIT
		GOTO GETSERIAL
    END IF

	SERIAL$ = GetSymbolValue("SERIAL")
	OWNER$  = GetSymbolValue("OWNER")

UPDATEIT:
	IF ValidateReg(SERIAL$) = 1 THEN
'*        l& = PutStringTable(DEST$)
		CreateIniKeyValue ini$, "PixFolio", "Registration Nbr", SERIAL$, cmoOverwrite
		CreateIniKeyValue ini$, "PixFolio", "Registered To", OWNER$, cmoOverwrite
	ELSE
		CreateProgmanItem "PixFolio", "Register", "notepad.exe "+MakePath(DEST$,"PIXREGST.FRM"), "", cmoOverwrite
	END IF

'*    Install
QUITWIN:
	ii% = RestartListEmpty()
	IF ii% = 0 THEN
		sz$ = UIStartDlg(CUIDLL$, QUITWIN, "FQuitWinDlgProc", 0, "")
		IF sz$ = "CONTINUE" THEN
			UIPop 1
		ELSEIF sz$ = "REACTIVATE" THEN
			GOTO QUITWIN
		ELSE
			GOSUB ASKQUIT
			GOTO QUITWIN
		END IF
		ij% = ExitExecRestart()
	END IF


QUIT:
    ON ERROR GOTO ERRQUIT

    IF ERR = 0 THEN
		IF ValidateReg(SERIAL$) = 1 THEN
			dlg% = EXITREGISTERED
		ELSE
			dlg% = EXITSUCCESS
		END IF
    ELSEIF ERR = STFQUIT THEN
	dlg% = EXITQUIT
    ELSE
	dlg% = EXITFAILURE
    END IF
QUITL1:
    sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
	GOTO QUITL1
    END IF
    UIPop 1

    END

ERRQUIT:
	i% = DoMsgBox("Setup sources were corrupted, call (502) 955-7527!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
    END

OPTFILES1:
	SetSymbolValue "RadioDefault", OPT1OPT$
OPT1L1:
	sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
	newopt$ = GetSymbolValue("ButtonChecked")

	IF sz$ = "CONTINUE" THEN
		UIPop 1
		IF newopt$ <> OPT1OPT$ THEN
			OPT1OPT$ = newopt$
			RecalcOptFiles OPTFILES1
			SetDriveStatus
		END IF
		newopt$ = ""
		GOTO CUSTINST
	ELSEIF sz$ = "REACTIVATE" THEN
		RecalcPath
		SetDriveStatus
		GOTO OPT1L1
	ELSEIF sz$ = "EXIT" THEN
		GOSUB ASKQUIT
		GOTO OPT1L1
	ELSE
		UIPop 1
		newopt$ = ""
		GOTO CUSTINST
	END IF



OPTFILES2:
	SetSymbolValue "RadioDefault", OPT2OPT$
OPT2L1:
	sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
	newopt$ = GetSymbolValue("ButtonChecked")

	IF sz$ = "CONTINUE" THEN
		UIPop 1
		IF newopt$ <> OPT2OPT$ THEN
			OPT2OPT$ = newopt$
			RecalcOptFiles OPTFILES2
			SetDriveStatus
		END IF
		newopt$ = ""
		GOTO CUSTINST
	ELSEIF sz$ = "REACTIVATE" THEN
		RecalcPath
		SetDriveStatus
		GOTO OPT2L1
	ELSEIF sz$ = "EXIT" THEN
		GOSUB ASKQUIT
		GOTO OPT2L1
	ELSE
		UIPop 1
		newopt$ = ""
		GOTO CUSTINST
	END IF

OPTFILES3:
	SetSymbolValue "RadioDefault", OPT3OPT$
OPT3L1:
	sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
	newopt$ = GetSymbolValue("ButtonChecked")

	IF sz$ = "CONTINUE" THEN
		UIPop 1
		IF newopt$ <> OPT3OPT$ THEN
			OPT3OPT$ = newopt$
			RecalcOptFiles OPTFILES3
			SetDriveStatus
		END IF
		newopt$ = ""
		GOTO CUSTINST
	ELSEIF sz$ = "REACTIVATE" THEN
		RecalcPath
		SetDriveStatus
		GOTO OPT3L1
	ELSEIF sz$ = "EXIT" THEN
		GOSUB ASKQUIT
		GOTO OPT3L1
	ELSE
		UIPop 1
		newopt$ = ""
		GOTO CUSTINST
	END IF

SYMFILES:
	SetSymbolValue "RadioDefault", SYMOPT$
OPTSL1:
	sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
	newopt$ = GetSymbolValue("ButtonChecked")

	IF sz$ = "CONTINUE" THEN
		UIPop 1
		IF newopt$ <> SYMOPT$ THEN
			SYMOPT$ = newopt$
			RecalcOptFiles SYMFILES
			SetDriveStatus
		END IF
		newopt$ = ""
		GOTO CUSTINST
	ELSEIF sz$ = "REACTIVATE" THEN
		RecalcPath
		SetDriveStatus
		GOTO OPTSL1
	ELSEIF sz$ = "EXIT" THEN
		GOSUB ASKQUIT
		GOTO OPTSL1
	ELSE
		UIPop 1
		newopt$ = ""
		GOTO CUSTINST
	END IF


TOOBIG:
	sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
	IF sz$ = "REACTIVATE" THEN
		RecalcPath
		SetDriveStatus
		GOTO TOOBIG
	END IF
	UIPop 1
	RETURN

NOAVI:
	sz$ = UIStartDlg(CUIDLL$, NOAVI, "FInfo0DlgProc", 0, "")
	IF sz$ = "REACTIVATE" THEN
		RecalcPath
		SetDriveStatus
		GOTO NOAVI
	END IF
	UIPop 1
	RETURN

NOAPP:
	sz$ = UIStartDlg(CUIDLL$, NOAPP, "FInfo0DlgProc", 0, "")
	IF sz$ = "REACTIVATE" THEN
		RecalcPath
		SetDriveStatus
		GOTO NOAPP
	END IF
	UIPop 1
	RETURN


BADPATH:
    sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
	GOTO BADPATH
    END IF
    UIPop 1
    RETURN


ASKQUIT:
    sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")

    IF sz$ = "EXIT" THEN
	UIPopAll
	ERROR STFQUIT
    ELSEIF sz$ = "REACTIVATE" THEN
	GOTO ASKQUIT
    ELSE
	UIPop 1
    END IF
    RETURN



'**
'** Purpose:
'**     Builds the copy list and performs all installation operations.
'** Arguments:
'**     none.
'** Returns:
'**     none.
'*************************************************************************
SUB Install STATIC

      lTicks& = 20

      SrcDir$ = GetSymbolValue("STF_SRCDIR")
      CreateDir DEST$, cmoNone
      ClearBillboardList
      AddToBillboardList CUIDLL$, MODELESS, "FModelessDlgProc", lTicks&

      OpenLogFile MakePath(DEST$, "LOGFILE.OUT"), 0
      WriteToLogFile ""
      WriteToLogFile "  User chose as destination directory: '" + DEST$ + "'"
      WriteToLogFile "  User chose option: '" + OPTCUR$ + "'"
      WriteToLogFile ""
      WriteToLogFile "May have had to create the directory: " + DEST$
      WriteToLogFile ""

      SetRestartDir(szTempDir)

      ClearCopyList
      AddOptFilesToCopyList APPFILES
      AddOptFilesToCopyList OPTFILES1
      AddOptFilesToCopyList OPTFILES2
      AddOptFilesToCopyList OPTFILES3
      AddOptFilesToCopyList SYMFILES


      AddSectionFilesToCopyList "Remove List", SrcDir$, DEST$

      IF NOPT$ = "0" THEN
	    cat1$ = MakePath(SrcDir$, "SMPL_"+MID$(SrcDir$,1,1)+".CAT")
	    cat2$ = MakePath(SrcDir$, "VR_I_E.CAT")
	    cat3$ = MakePath(SrcDir$, "WB_1TO3.CAT")
	    cat4$ = MakePath(SrcDir$, "WB_4to6.CAT")
	    cat5$ = MakePath(SrcDir$, "DINO_I.CAT")
	    cat6$ = MakePath(SrcDir$, "FAL_I_D.CAT")
	    cat7$ = MakePath(SrcDir$, "GEM_I_D.CAT")
	    cat8$ = MakePath(SrcDir$, "AGB_I_E.CAT")
       ELSE
	    AddSectionFilesToCopyList "Catalogs", SrcDir$, DEST$
	    AddSectionFilesToCopyList "Sampler_"+MID$(SrcDir$,1,1), SrcDir$, DEST$
	    cat1$ = MakePath(DEST$, "SMPL_"+MID$(SrcDir$,1,1)+".CAT")
	    cat2$ = MakePath(DEST$, "VR_I_E.CAT")
	    cat3$ = MakePath(DEST$, "WB_1TO3.CAT")
	    cat4$ = MakePath(DEST$, "WB_4to6.CAT")
	    cat5$ = MakePath(DEST$, "DINO_I.CAT")
	    cat6$ = MakePath(DEST$, "FAL_I_D.CAT")
	    cat7$ = MakePath(DEST$, "GEM_I_D.CAT")
	    cat8$ = MakePath(DEST$, "AGB_I_E.CAT")
      END IF

      CopyFilesInCopyList

      vol$ = "              "
      GetVolume SrcDir$, vol$
      Ext$ = "*.GIF;*.BMP;*.TIF;*.TGA;*.IFF;*.PCX;*.WMF;*.EPS;*.WPG;*.PCD"
      i% = DoesFileExist(cat$, femExists)
      j% = DoesIniSectionExist("WIN.INI", "PixFolio")
      IF i = 1 And j = 0 THEN
		'' CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog1", "Default," + cat$ + "," + Ext$ +"," + vol$ + ",READONLY", cmoNone
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog99", "Fashion Advertising Lifestyle," + cat6$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog98", "Visual Rythms," + cat2$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog97", "WorldBank Volumes I to III," + cat3$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog96", "WorldBank Volumes IV to VI," + cat4$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog95", "Jurassic Dinosaurs," + cat5$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog94", "Sample Images from WorldBank," + cat1$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog93", "Gems," + cat7$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog92", "Abstract & Graphic Backgrounds," + cat8$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalogs", "99", cmoNone
	ELSE
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog99", "Fashion Advertising Lifestyle," + cat6$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog98", "Visual Rythms," + cat2$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog97", "WorldBank Volumes I to III," + cat3$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog96", "WorldBank Volumes IV to VI," + cat4$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog95", "Jurassic Dinosaurs," + cat5$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog94", "Sample Images from WorldBank," + cat1$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog93", "Gems," + cat7$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalog92", "Abstract & Graphic Backgrounds," + cat8$ + "," + Ext$ + ", , READONLY", cmoOverwrite
		CreateIniKeyValue "WIN.INI", "PixFolio", "Catalogs", "99", cmoNone
	ENDIF

	IF DoesFileExist(MakePath(DEST$, "PIXPCD.DLL"), femReadWrite) = 1 THEN
		CreateIniKeyValue "WIN.INI", "PixFolio", "PCD Resolution", "3", cmoNone
		CreateIniKeyValue "WIN.INI", "PixFolio", "PCD Format", "2", cmoNone
	END IF

	CreateProgmanGroup "PixFolio", "", cmoNone
	ShowProgmanGroup  "PixFolio", 1, cmoNone
	CreateProgmanItem "PixFolio", "PixFolio", MakePath(DEST$,"PixFolio"), "", cmoOverwrite
	CreateProgmanItem "PixFolio", "Read Me", "NotePad.exe "+MakePath(DEST$,"PIXREAD.ME"), "", cmoOverwrite
	CreateProgmanItem "PixFolio", "User Guide", "Write.exe "+MakePath(DEST$,"UsrGuide.wri"), "", cmoOverwrite
	CreateProgmanItem "PixFolio", "License Agreement", "Notepad.exe "+MakePath(DEST$,"LICENSE.TXT"), "", cmoOverwrite
	CreateProgmanItem "PixFolio", "Other Products", "NotePad.exe "+MakePath(DEST$,"OTH_PROD.TXT"), "", cmoOverwrite
	CloseLogFile

END SUB



'**
'** Purpose:
'**     Appends a file name to the end of a directory path,
'**     inserting a backslash character as needed.
'** Arguments:
'**     szDir$  - full directory path (with optional ending "\")
'**     szFile$ - filename to append to directory
'** Returns:
'**     Resulting fully qualified path name.
'*************************************************************************
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

'**
'** Purpose:
'**     Adds the specified option files to the copy list.
'** Arguments:
'**     ftype%  - type of files to add, one of the following:
'**             APPFILES, OPTFILES1, OPTFILES2
'** Returns:
'**     none.
'*************************************************************************
SUB AddOptFilesToCopyList (ftype%) STATIC

	IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
		SrcDir$ = GetSymbolValue("STF_SRCDIR")
		IF ftype% = APPFILES THEN
			AddSectionFilesToCopyList "PixFolio Files", SrcDir$, DEST$
			AddSectionFilesToCopyList "System Files", SrcDir$, SysDir$
		ELSEIF ftype% = OPTFILES1 THEN
						'' Not any more
			AddSectionFilesToCopyList "PCD Files", SrcDir$, DEST$
		ELSEIF ftype% = OPTFILES2 THEN
			AddSectionFilesToCopyList "VFW Files", SrcDir$, DEST$
		ELSEIF ftype% = OPTFILES3 THEN
			AddSectionFilesToCopyList "Multimedia Files", SrcDir$, DEST$
		ELSEIF ftype% = SYMFILES THEN
''            i% = DoMsgBox("AddOptFiles" + STR$(ftype%), "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
			IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
				AddSectionFilesToCopyList "PixFolio Symbols", SrcDir$, DEST$
			END IF
			IF GetListItem(CHECKSTATES$, OPTFILES1) = "ON" THEN
				AddSectionFilesToCopyList "PCD Symbols", SrcDir$, DEST$
			END IF
			IF GetListItem(CHECKSTATES$, OPTFILES2) = "ON" THEN
				AddSectionFilesToCopyList "VFW Symbols", SrcDir$, DEST$
			END IF
			IF GetListItem(CHECKSTATES$, OPTFILES3) = "ON" THEN
				AddSectionFilesToCopyList "Multimedia Symbols", SrcDir$, DEST$
			END IF
		END IF
		SrcDir$ = ""
	END IF
END SUB

'**
'** Purpose:
'**     Recalculates disk space for the given option files and sets
'**     the status info symbol "StatusItemsText".
'** Arguments:
'**     ftype% - type of files to add, one of the following:
'**             APPFILES, OPTFILES1, OPTFILES2
'** Returns:
'**     none.
'*************************************************************************
SUB RecalcOptFiles (ftype%) STATIC
	CursorSave% = ShowWaitCursor()
	ClearCopyList
	AddOptFilesToCopyList ftype%
''    i% = DoMsgBox("Added files to copy list " + STR$(ftype%), "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
	fExtra% = 0
	IF ftype% = APPFILES THEN
		ListSym$ = APPNEEDS$
		IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
			''Add extra cost to Windows drive for ini/progman, etc.
			ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
			ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
			fExtra% = 1
		END IF
	ELSEIF ftype% = OPTFILES1 THEN
		ListSym$ = OPT1NEEDS$
	ELSEIF ftype% = OPTFILES2 THEN
		ListSym$ = OPT2NEEDS$
	ELSEIF ftype% = OPTFILES3 THEN
		ListSym$ = OPT3NEEDS$
	ELSEIF ftype% = SYMFILES THEN
		ListSym$ = SYMNEEDS$
	END IF
''    i% = DoMsgBox("ListSym$ =" + ListSym$, "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
	StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")

	cost& = 0

	FOR i% = 1 TO 26 STEP 1
		cost&  = cost& + VAL(GetListItem(ListSym$, i%))
	NEXT i%
	IF NOPT$ = "1" THEN
	    ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K (Including Catalog)"
	ELSE
	    ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
	END IF


	IF StillNeed& > 0 THEN
		ReplaceListItem BIGLIST$, ftype%, "YES"
	ELSE
		ReplaceListItem BIGLIST$, ftype%, ""
	END IF

	IF fExtra% THEN
		ReplaceListItem EXTRACOSTS$, ndrive%, "0"
	END IF
	RestoreCursor CursorSave%
	ListSym$ = ""
''    i% = DoMsgBox("RecalcPath OK" + STR$(ftype%), "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
END SUB


'**
'** Purpose:
'**     Recalculates disk space and sets option status info according
'**     to the current destination path.
'** Arguments:
'**     none.
'** Returns:
'**     none.
'*************************************************************************
SUB RecalcPath STATIC

	CursorSave% = ShowWaitCursor()

	RecalcOptFiles APPFILES
	RecalcOptFiles OPTFILES1
	RecalcOptFiles OPTFILES2
	RecalcOptFiles OPTFILES3
	RecalcOptFiles SYMFILES

	RestoreCursor CursorSave%
END SUB


'**
'** Purpose:
'**     Sets drive status info according to latest disk space calcs.
'** Arguments:
'**     none.
'** Returns:
'**     none.
'*************************************************************************
SUB SetDriveStatus STATIC

	drive$ = MID$(DEST$, 1, 1)
	ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
	cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%)) + VAL(GetListItem(SYMNEEDS$, ndrive%))
	free& = GetFreeSpaceForDrive(drive$)

''======================================================================
'' Manual posting of catalog size for now until new version is made.
''======================================================================
'' If catalog on HD is selected add 41472626 to total needed.        

	IF NOPT$ = "1" THEN
	  cost& = cost& + 42284334
	END IF

''=====================================================================
	
	ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
	ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
	ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"

	IF drive$ = WINDRIVE$ THEN
		ReplaceListItem DRIVETEXT$, 4, ""
		ReplaceListItem DRIVETEXT$, 5, ""
		ReplaceListItem DRIVETEXT$, 6, ""
	ELSE
		ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
		cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
		IF cost& = 0 THEN
			ReplaceListItem DRIVETEXT$, 4, ""
			ReplaceListItem DRIVETEXT$, 5, ""
			ReplaceListItem DRIVETEXT$, 6, ""
		ELSE
			''IF NOPT$ = "1" THEN
			''  cost& = cost& + 1146712
			''END IF
			free& = GetFreeSpaceForDrive(WINDRIVE$)
			ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
			ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
			ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
		END IF
	END IF
END SUB

