'**************************************************************************
'*                       MSSetup Toolkit Sample 2
'**************************************************************************

'$DEFINE DEBUG  ''Define for script development/debugging

'$INCLUDE 'setupapi.inc'
'$INCLUDE 'msdetect.inc'     
'$INCLUDE 'msregdb.inc'

''---Dialog ID's
CONST WELCOME      	= 100       
CONST REGISTERBOX	= 200 
CONST CUSTINST     	= 300
CONST EXITFAILURE  	= 400
CONST EXITSUCCESS  	= 500
CONST APPHELP      	= 600
CONST ASKQUIT      	= 700
CONST DESTPATH     	= 800
CONST TOOBIG		= 900
CONST BADPATH      	= 1000
CONST NAMEREQD		= 1100
CONST SERREQD		= 1200
CONST FILEEXIST		= 1300	
     
''---Bitmap ID           
''CONST LOGO1         = 100
     
''---File Types
CONST AppFiles     = 1
CONST OptFiles1    = 2
CONST OptFiles2    = 3
CONST OptFiles3    = 4
CONST OptFiles4    = 5
CONST OptFiles5    = 6
CONST OptFiles6    = 7 
CONST OptFiles7    = 8

        
GLOBAL SOURCE$      ''Source drive/directory
GLOBAL SDRIVE%
GLOBAL DEST$        ''Default destination directory.
GLOBAL OPDEST$      ''Default destination directory.
GLOBAL SUB1$        ''SubDir
GLOBAL SUB2$        ''SubDir
GLOBAL SUB3$        ''SubDir
GLOBAL SUB4$        ''SubDir
GLOBAL SUB5$        ''SubDir 
GLOBAL SUB6$        ''SubDir
GLOBAL WINDRIVE$    ''Windows drive letter. 
GLOBAL WINDIR$      ''Windows DIR.


''---CustInst list symbol names
GLOBAL APPNEEDS$    ''Option list costs per drive
GLOBAL OPT1NEEDS$	''Option list costs per drive
GLOBAL OPT2NEEDS$	''Option list costs per drive



GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
    
''---NameOrgSer symbol table names
GLOBAL USERNAMEL$    ''User Name string variable
GLOBAL ORGNAMEL$     ''User Organization Name string variable
GLOBAL SERNUMBERL$   ''Product Serial Number string variable

''---NameOrgSer string variables
GLOBAL UserName$
GLOBAL OrgName$
GLOBAL SerialNumber$
    
''---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 FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE FUNCTION ShellExecute% Lib "SHELL.DLL" (hwnd%, szOp$, szFile$, szParms$, szDir$, show%)


INIT:
    CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
    HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
''  SetBitmap CUIDLL$, LOGO1
    SetTitle "CheckIt Analyst"
    
    szInf$ = GetSymbolValue("STF_SRCINFPATH")
    IF szInf$ = "" THEN
        szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
    END IF    
    ReadInfFile szInf$
                    
    ''---Set up Source, Windows, and Dest paths
    SOURCE$ = GetSymbolValue ("STF_SRCDIR")
    SDRIVE% = ASC(ucase$(SOURCE$)) - ASC("A") + 1
    WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
    WINDIR$ = GetWindowsDir()
	OPDEST$ = "D:\"        
    
    DEST$ = WINDRIVE$ + ":\ANALYST"
    SUB1$ = DEST$ + "\ADVISOR"
	SUB2$ = DEST$ + "\SOFTWARE"        
	SUB3$ = DEST$ + "\PRF"
	SUB4$ = DEST$ + "\REPORTS"
    SUB5$ = DEST$ + "\DATA"	 
	SUB6$ = DEST$ + "\PIF"	     

    ''---CustInst list symbols
    CHECKSTATES$ = "CheckItemsState"
    STATUSTEXT$  = "StatusItemsText"
    DRIVETEXT$   = "DriveStatusText"

    FOR i% = 1 TO 3 STEP 1
        AddListItem CHECKSTATES$, "ON"
    NEXT i%
    
    FOR i% = 1 TO 3 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"
                             
    EXTRACOSTS$ = "ExtraCosts"
    BIGLIST$    = "BigList"
    FOR i% = 1 TO 3 STEP 1
        AddListItem BIGLIST$, ""
    NEXT i%
    FOR i% = 1 TO 26 STEP 1
        AddListItem EXTRACOSTS$, "0"
    NEXT i%
         
    RecalcPath
    SetDriveStatus

'$IFDEF DEBUG
    i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
'$ENDIF ''DEBUG


'\*
' *
' *      Show the Introduction screen
' *
' */
WELCOME:
    IF WINMAJOR% = 3 and WINMINOR% = 00  THEN
		i% = DoMsgBox("This program requires Windows version 3.1", "Error - 01", IDOK)            
		END
	ENDIF                                                            

	sz$ = UIStartDlg(CUIDLL$, WELCOME, "FCustInstDlgProc", 0, "")    
    IF sz$ = "CONTINUE" THEN
		UIPop 1    
		GOTO REGISTERBOX
    ELSEIF sz$ = "BTN1" THEN
        j% = ShellExecute(hMainWnd, "open", SOURCE$+"README.WRI", "", "", 1)
        IF j% < 32 THEN
			GOTO ERRQUIT
        END IF     
		GOTO WELCOME
	ELSEIF sz$ = "EXIT" THEN
		UIPop 1    	
        GOSUB ASKQUIT
        GOTO WELCOME
    ELSE
		GOTO WELCOME            
    END IF   
             

'\*
' *
' *      Get the User's Name, Organization, Serial#
' *
' */    
REGISTERBOX:            
	UIPop 1    
    SetSymbolValue "NameOut", ""
    SetSymbolValue "OrgOut",  ""
    SetSymbolValue "SerOut",  ""
NOS1:    
	sz$ = UIStartDlg(CUIDLL$, REGISTERBOX, "FNameOrgDlgProc", APPHELP, HELPPROC$)    
    IF sz$ = "CONTINUE" THEN
        UserName$ 		= GetSymbolValue("NameOut")
        OrgName$ 		= GetSymbolValue("OrgOut")                
        SerialNumber$ 	= GetSymbolValue("SerOut")
            
        IF UserName$ = "" THEN                      ''NULL user name not allowed.
            GOTO NAMEREQD
        END IF
            
        IF SerialNumber$ = "" THEN					''NULL serial number not allowed.
            GOTO SERREQD
        END IF          
        
	ELSEIF sz$ = "BACK" THEN
    	UIPop 1    	    
    	GOTO WELCOME
    	
	ELSEIF sz$ = "EXIT" THEN
        UIPop 1    	
        GOSUB ASKQUIT
        GOTO NOS1
	END IF
	    

CUSTINST1:
    UIPop 1    	
    FOR i% = 1 TO 3 STEP 1
        AddListItem CHECKSTATES$, "ON"
    NEXT i%
    
CUSTINST:
    sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
    
	RecalcOptFiles AppFiles
	RecalcOptFiles OptFiles1           
	RecalcOptFiles OptFiles2    

    IF sz$ = "CONTINUE" THEN
        ''Install only if it will fit.
        FOR i% = 1 TO 3 STEP 1
            IF GetListItem(BIGLIST$, i%) <> "" THEN
                GOSUB TOOBIG
                GOTO CUSTINST
            END IF
        NEXT i%
        UIPop 1
        GOTO INSTALL  
	END IF	      
	
    IF sz$ = "PATH" THEN
        GOTO GETPATH
	END IF	              
        
    IF sz$ = "CHK1" THEN
        RecalcOptFiles APPFILES
        SetDriveStatus
        GOTO CUSTINST   
	END IF	      
	        
    IF sz$ = "CHK2" THEN
'        RecalcOptFiles OptFiles1
        SetDriveStatus
        GOTO CUSTINST   
	END IF	      
	        
    IF sz$ = "CHK3" THEN        
        RecalcOptFiles OptFiles1
        RecalcOptFiles OptFiles2        
        SetDriveStatus
        GOTO CUSTINST
	END IF	          
    
    IF sz$ = "REACTIVATE" THEN
        RecalcPath
        SetDriveStatus
        GOTO CUSTINST
	END IF	              

	IF sz$ = "BACK" THEN
        UIPop 1    	
		GOTO NOS1        
    END IF

	IF sz$ = "EXIT" THEN
        UIPop 1    	
        GOSUB ASKQUIT
        GOTO CUSTINST
    END IF


INSTALL:                

	''Validate old file Exist.              
'	i% = DoesFileExist(DEST$+"\CKANLYST.EXE",femExists)
'	IF i% = 1 THEN
'	    UIPop 1
'		sz$ = UIStartDlg(CUIDLL$, FILEEXIST, "FCustInstDlgProc", 0, "")
'		IF sz$ = "EXIT" THEN    
'			UIPop 1             
'			GOTO CUSTINST1				
'	    END IF
'	ENDIF			

        
	SetCopyGaugePosition 80,80
	SYSDEST$ = GetWindowsSysDir()
	SrcDir$ = GetSymbolValue("STF_SRCDIR")

    SUB1$ = DEST$ + "\ADVISOR"
	SUB2$ = DEST$ + "\SOFTWARE"        
	SUB3$ = DEST$ + "\PRF"
	SUB4$ = DEST$ + "\REPORTS"
    SUB5$ = DEST$ + "\DATA"	 
	SUB6$ = DEST$ + "\PIF"	     

    ClearCopyList                                      
    
	IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN    
		AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$    	
    	CreateDir DEST$, cmoNone   		
	    
		AddSectionFilesToCopyList "OptFiles3", SrcDir$, SUB3$    	
    	CreateDir SUB3$, cmoNone		
		
''		AddSectionFilesToCopyList "OptFiles4", SrcDir$, SUB4$    	
    	CreateDir SUB4$, cmoNone		 
		
		AddSectionFilesToCopyList "OptFiles5", SrcDir$, SUB5$    	
    	CreateDir SUB5$, cmoNone		
		
		AddSectionFilesToCopyList "OptFiles6", SrcDir$, SUB6$    			    
    	CreateDir SUB6$, cmoNone		
	END IF    	

    IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
		AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$    	    	
    END IF

    IF GetListItem(CHECKSTATES$, OPTFILES1) = "ON" THEN
		AddSectionFilesToCopyList "OptFiles7", SrcDir$, DEST$    	    	
    END IF
    
    IF GetListItem(CHECKSTATES$, OPTFILES2) = "ON" THEN
		AddSectionFilesToCopyList "OptFiles1", SrcDir$, SUB1$    	
	    CreateDir SUB1$, cmoNone		
		AddSectionFilesToCopyList "OptFiles2", SrcDir$, SUB2$    	
    	CreateDir SUB2$, cmoNone                 		
    END IF

	IF (GetListItem(CHECKSTATES$, OPTFILES1) <> "ON") AND (GetListItem(CHECKSTATES$, OPTFILES2) <> "ON") AND (GetListItem(CHECKSTATES$, APPFILES) <> "ON")  THEN
	    i% = DoMsgBox(" No Option was selected ", "Error", IDCOK)
    	GOTO CUSTINST 	    
    END IF     
            
	UIPopAll            
    CopyFilesInCopyList    


	i% = DoesFileExist(WINDIR$+"CKANLYST.OLD", femExists)
	IF i% = 1 THEN
		RemoveFile WINDIR$+"CKANLYST.OLD", cmoForce
	ENDIF		
	
	i% = DoesFileExist(WINDIR$+"DOSAPP.OLD", femExists)
	IF i% = 1 THEN
		RemoveFile WINDIR$+"DOSAPP.OLD", cmoForce
	ENDIF		

	i% = DoesFileExist(WINDIR$+"CKANLYST.INI", femExists)
	IF i% = 1 THEN
		RenameFile WINDIR$+"CKANLYST.INI", "CKANLYST.OLD"
	ENDIF		
	
	i% = DoesFileExist(WINDIR$+"DOSAPP.INI", femExists)
	IF i% = 1 THEN
		RenameFile WINDIR$+"DOSAPP.INI", "DOSAPP.OLD"
	ENDIF		
	
    
    ini$ = MakePath(WINDIR$, "CKANLYST.INI")
    CreateIniKeyValue ini$,    "Directories", "Program", 		DEST$, cmoOverwrite
    CreateSysIniKeyValue ini$, "Directories", "Help",       	DEST$, cmoNone    
    CreateSysIniKeyValue ini$, "Directories", "Setup Advisor", 	SUB1$, cmoNone     
    CreateSysIniKeyValue ini$, "Directories", "Software",   	SUB2$, cmoNone    
    CreateSysIniKeyValue ini$, "Directories", "PRF",        	SUB3$, cmoNone    
    CreateSysIniKeyValue ini$, "Directories", "Reports",    	SUB4$, cmoNone
    CreateSysIniKeyValue ini$, "Directories", "Data",       	SUB5$, cmoNone
    CreateSysIniKeyValue ini$, "Directories", "PIF Files",  	SUB6$, cmoNone    
    
    CreateIniKeyValue ini$, "Exclude", "WIN", "", cmoOverwrite     
    CreateIniKeyValue ini$, "Exclude", "DOS", "", cmoOverwrite        

CreateIniKeyValue ini$, "Settings", "prf", "DOS8088.PRF,DOS28616.PRF,DOS386SX.PRF,WIN38625.PRF,WIN386SX.PRF,DOS386CH.PRF,DOS486LP.PRF,WIN48650.PRF,WINPENT.PRF,DOSPENT.PRF", cmoOverwrite                 
CreateIniKeyValue ini$, "Settings", "Show Vendor", "FALSE", cmoOverwrite        
    
    CreateIniKeyValue ini$, "Configuration Files", "Last Used", "", cmoOverwrite        

    CreateSysIniKeyValue ini$, "INSTALL", "Version",	"1.10",   cmoNone    
    CreateIniKeyValue ini$,    "INSTALL", "SN",			SerialNumber$, cmoOverwrite
    CreateSysIniKeyValue ini$, "INSTALL", "User", 		UserName$,     cmoNone    
    CreateSysIniKeyValue ini$, "INSTALL", "Company", 	OrgName$ ,     cmoNone        
    
    CreateIniKeyValue ini$, "System", "Restart", "FALSE", cmoOverwrite
    ini$ = ""                  

	ini$ = MakePath(WINDIR$, "DOSAPP.INI")
	CreateSysIniKeyValue ini$, "DOS Applications", SUB6$+"\CKSYS.PIF",   "1 8 12 648 328 22 0 1 65535 65535 116 110 20 50 620 215", cmoAppend    	    		
	CreateSysIniKeyValue ini$, "DOS Applications", SUB6$+"\CKMEM.PIF",   "1 8 12 648 328 22 0 1 65535 65535 20 50 620 215", cmoAppend    	    		
	CreateSysIniKeyValue ini$, "DOS Applications", SUB6$+"\CKHD.PIF",    "1 8 12 648 328 22 0 1 65535 65535 92 88 20 50 620 215", cmoAppend    	    	
	CreateSysIniKeyValue ini$, "DOS Applications", SUB6$+"\CKFD.PIF",    "1 8 12 648 328 22 0 1 65535 65535 65535 65535 20 50 620 215", cmoAppend    	    	
	CreateSysIniKeyValue ini$, "DOS Applications", SUB6$+"\CKCOM.PIF",   "1 8 12 648 328 22 0 1 65535 65535 44 44 20 50 620 215", cmoAppend    	    	
	CreateSysIniKeyValue ini$, "DOS Applications", SUB6$+"\CKLPT.PIF",   "1 8 12 648 328 22 0 1 65535 65535 65535 65535 20 50 620 215", cmoAppend    	    	
	CreateSysIniKeyValue ini$, "DOS Applications", SUB6$+"\CKRUN.PIF",   "1 8 12 648 328 22 0 1 65535 65535 65535 65535 100 200 500 340", cmoAppend    	    	
	CreateSysIniKeyValue ini$, "DOS Applications", SUB6$+"\CKCOLECT.PIF","1 8 12 648 328 22 0 1 65535 65535 65535 65535 100 200 579 315", cmoAppend    	    	
         
	CopyFile WINDIR$+"CKANLYST.INI", DEST$+"\CKAINI.SAV", cmoOverwrite, 0
	         
	IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN    
		CreateProgmanGroup "Analyst", "", cmoNone
		ShowProgmanGroup  "Analyst", 1, cmoNone
		CreateProgmanItem "Analyst", "CheckIt Analyst", MakePath(DEST$,"CKANLYST.EXE"), "", cmoOverwrite
		CreateProgmanItem "Analyst", "Read Me", "write.exe "+MakePath(DEST$,"README.WRI"), "", cmoOverwrite 
		CreateProgmanItem "Analyst", "CKWDATA", MakePath(DEST$,"CKWDATA.EXE"), "", cmoOverwrite
	END IF    

QUIT:
    ON ERROR GOTO ERRQUIT

    IF ERR = 0 THEN
        dlg% = EXITSUCCESS
    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 Tech.Support", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
    END


ASKQUIT:            
	UIPop 1    	
    sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
	
    IF sz$ = "EXIT" THEN
        UIPopAll
        ERROR EXITFAILURE
    ELSEIF sz$ = "REACTIVATE" THEN
        GOTO ASKQUIT
    ELSE
        UIPop 1
    END IF
    RETURN



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

        ''Validate old file Exist.              
		i% = DoesFileExist(DEST$+"\CKANLYST.EXE",femExists)
		IF i% = 1 THEN
		    UIPop 1
			sz$ = UIStartDlg(CUIDLL$, FILEEXIST, "FCustInstDlgProc", 0, "")
			IF sz$ = "EXIT" THEN    
				UIPop 1             
				GOTO GETPATHL1				
		    END IF
		ENDIF			

        olddest$ = ""
        GOTO CUSTINST1
        
    ELSEIF sz$ = "REACTIVATE" THEN
        RecalcPath
        SetDriveStatus
        GOTO GETPATHL1
    ELSEIF sz$ = "EXIT" THEN
        GOSUB ASKQUIT
        GOTO GETPATHL1
    ELSE
        UIPop 1
        GOTO CUSTINST
    END IF


TOOBIG:
    sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
        RecalcPath
        SetDriveStatus
        GOTO TOOBIG
    END IF
    UIPop 1
    RETURN


BADPATH:
    sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
        RecalcPath
        SetDriveStatus
        GOTO BADPATH
    END IF
    UIPop 1
    RETURN
        
        
FILEEXIST:    
	UIPopAll
    sz$ = UIStartDlg(CUIDLL$, FILEEXIST, "FCustInstDlgProc", 0, "")
	
	IF sz$ = "EXIT" THEN    
	    UIPop 1
		GOTO GETPATH        
	ELSE		
	    UIPop 1
	   	RETURN
    END IF
    


NAMEREQD:
    sz$ = UIStartDlg(CUIDLL$, NAMEREQD, "FInfo0DlgProc", 0, "")    
    IF sz$ = "CONTINUE" THEN
    	UIPop 1    
        GOTO NOS1
    END IF


SERREQD:
    sz$ = UIStartDlg(CUIDLL$, SERREQD, "FInfo0DlgProc", 0, "")    
    IF sz$ = "CONTINUE" THEN    
    	UIPop 1    
        GOTO NOS1
    END IF


'**
'** 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 "AppFiles", SrcDir$, DEST$
			AddSectionFilesToCopyList "OptFiles3", SrcDir$, SUB3$            
			AddSectionFilesToCopyList "OptFiles5", SrcDir$, SUB5$				
            AddSectionFilesToCopyList "OptFiles6", SrcDir$, SUB6$			
            
        ELSEIF ftype% = OptFiles1 THEN
            AddSectionFilesToCopyList "OptFiles7", SrcDir$, DEST$
			
        ELSEIF ftype% = OptFiles2 THEN
            AddSectionFilesToCopyList "OptFiles1", SrcDir$, SUB1$ 
            AddSectionFilesToCopyList "OptFiles2", SrcDir$, SUB2$            
            
        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%

    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$
    END IF

    StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")

    cost& = 0
    FOR i% = 1 TO 26 STEP 1
        cost&  = cost& + VAL(GetListItem(ListSym$, i%))
    NEXT i%
    ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
    

    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$ = ""
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
                                
    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%))
    free& = GetFreeSpaceForDrive(drive$)
    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%))
		cost& = 1024        
		
        IF cost& = 0 THEN
            ReplaceListItem DRIVETEXT$, 4, ""
            ReplaceListItem DRIVETEXT$, 5, ""
            ReplaceListItem DRIVETEXT$, 6, ""
        ELSE
            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


'**
'** 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

