'' $Keywords: draw2.mst 1.15 21Jul93 09:42am$ $nokeywords$
'**
'** Purpose:
'**     Adds the specified option files to the copy list.
'** Arguments:
'**     ftype%  - type of files to add, one of the following:
'**             DRAW, CHART, SHOW, PHOTO, MOVE, TRACE, MOSAIC, FILTERS or FONTTT
'** Returns:
'**     none.
'*************************************************************************
SUB AddOptFilesToCopyList (ftype%) STATIC

	fState% = afState(ftype%)
	IF bInstallNet% THEN
		RedistWinDir$ = MakePath(DIR(MAIN),TR_REDIST)
	ELSE
		RedistWinDir$ = WINDIR$
	ENDIF
		
	SELECT CASE ftype%
	CASE DRAW
		bInstall(DRAW) = FALSE
		bInstallClipart% = FALSE
		IF fState% <> NONE THEN
			IF fState% = ALL OR GetListItem( OPTS(DRAW), 1 ) = "ON" THEN
				AddSectionFilesToCopyList "DrawMain", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
				AddSectionFilesToCopyList "DrawDraw", SrcDir$, DIR(DRAW)
				AddSectionFilesToCopyList "DrawEhandler", SrcDir$, MakePath(DIR(DRAW), TR_EHANDLER)
				AddSectionFilesToCopyList "DrawConfig", SrcDir$, MakePath(DIR(MAIN),TR_CONFIG)
				AddSectionFilesToCopyList "DrawTemplate", SrcDir$, MakePath(DIR(DRAW),TR_TEMPLATE)
				''The Common Bullets should be always installed with DRAW 	
				AddSectionKeyFileToCopyList "WFN", TR_COMMONBULLETS, SrcDir$, MakePath(DIR(MAIN),TR_SYMBOLS)
				bInstall(DRAW) = TRUE
			ENDIF
			IF fState% = ALL OR GetListItem( OPTS(DRAW), 2 ) = "ON" THEN
				AddSectionFilesToCopyList "DrawHelp", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
			ENDIF
			IF fState% = ALL OR GetListItem( OPTS(DRAW), 3 ) = "ON" THEN
				AddSectionFilesToCopyList "DrawSamples", SrcDir$, MakePath(DIR(DRAW), TR_SAMPLES)
			ENDIF
			IF fState% = ALL THEN
				''Add all the symbols specified using SelectSymbols or default
				AddSectionFilesToCopyList "WFN", SrcDir$, MakePath(DIR(MAIN),TR_SYMBOLS)
			ELSEIF fState% = SOME AND	GetListItem( OPTS(DRAW), 4 ) = "ON" THEN
				FOR nIndex% = 1 TO GetListLength(SYMBOLLIST2$)
					AddSectionKeyFileToCopyList "WFN", GetListItem(SYMBOLLIST2$, nIndex%), SrcDir$, MakePath(DIR(MAIN),TR_SYMBOLS)
				NEXT nIndex%
			ENDIF
			'$IFNDEF INSTALLCD
			IF fState% = ALL OR GetListItem( OPTS(DRAW), 5 ) = "ON" THEN
					AddSectionFilesToCopyList "Clipart", SrcDir$, MakePath(DIR(MAIN),TR_CLIPART)
					bInstallClipart% = TRUE
			ENDIF
			'$ENDIF
		ENDIF
			
	CASE CHART
		bInstall(CHART) = FALSE
		IF fState% <> NONE THEN
			IF fState% = ALL OR GetListItem( OPTS(CHART), 1 ) = "ON" THEN
				AddSectionFilesToCopyList "ChartMain", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
				AddSectionFilesToCopyList "Chart3driser", SrcDir$, MakePath(DIR(CHART), TR_3DRISER)
				AddSectionFilesToCopyList "Chart3dscat", SrcDir$, MakePath(DIR(CHART), TR_3DSCAT)
				AddSectionFilesToCopyList "ChartArea", SrcDir$, MakePath(DIR(CHART), TR_AREA)
				AddSectionFilesToCopyList "ChartBar", SrcDir$, MakePath(DIR(CHART), TR_BAR)
				AddSectionFilesToCopyList "ChartHilo", SrcDir$, MakePath(DIR(CHART), TR_HILO)
				AddSectionFilesToCopyList "ChartHist", SrcDir$, MakePath(DIR(CHART), TR_HIST)
				AddSectionFilesToCopyList "ChartLine", SrcDir$, MakePath(DIR(CHART), TR_LINE)
				AddSectionFilesToCopyList "ChartPicto", SrcDir$, MakePath(DIR(CHART), TR_PICTO)
				AddSectionFilesToCopyList "ChartPie", SrcDir$, MakePath(DIR(CHART), TR_PIE)
				AddSectionFilesToCopyList "ChartScatter", SrcDir$, MakePath(DIR(CHART), TR_SCATTER)
				AddSectionFilesToCopyList "ChartSpectral", SrcDir$, MakePath(DIR(CHART), TR_SPECTRAL)
				AddSectionFilesToCopyList "ChartTable", SrcDir$, MakePath(DIR(CHART), TR_TABLE)
				AddSectionFilesToCopyList "ChartConfig", SrcDir$, MakePath(DIR(MAIN),TR_CONFIG)
				bInstall(CHART) = TRUE
			ENDIF
			IF fState% = ALL OR GetListItem( OPTS(CHART), 2 ) = "ON" THEN
				AddSectionFilesToCopyList "ChartHelp", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
			ENDIF
			IF fState% = ALL OR GetListItem( OPTS(CHART), 3 ) = "ON" THEN
				AddSectionFilesToCopyList "ChartSamples", SrcDir$, MakePath(DIR(CHART), TR_SAMPLES)
			ENDIF
		ENDIF
			
	CASE SHOW
		bInstall(SHOW) = FALSE
		IF fState% <> NONE THEN
			IF fState% = ALL OR GetListItem( OPTS(SHOW), 1 ) = "ON" THEN
				AddSectionFilesToCopyList "ShowMain", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
				AddSectionFilesToCopyList "ShowConfig", SrcDir$, MakePath(DIR(MAIN),TR_CONFIG)
				AddRedistSection "ShowRedist"
				AddSectionFilesToCopyList "ShowRedistWin", SrcDir$, RedistWinDir$
				bInstall(SHOW) = TRUE
			ENDIF
			IF fState% = ALL OR GetListItem( OPTS(SHOW), 2 ) = "ON" THEN
				AddSectionFilesToCopyList "ShowFlics", SrcDir$, MakePath(DIR(SHOW),TR_FLICS)
				AddSectionFilesToCopyList "ShowBackgrds", SrcDir$, MakePath(DIR(SHOW),TR_BACKGRDS)
			ENDIF
		ENDIF
			
	CASE PHOTO
		bInstall(PHOTO) = FALSE
		IF fState% <> NONE THEN
			IF fState% = ALL OR GetListItem( OPTS(PHOTO), 1 ) = "ON" THEN
				AddSectionFilesToCopyList "PhotoMain", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
				AddSectionFilesToCopyList "PhotoPhoto", SrcDir$, DIR(PHOTO)
				AddSectionFilesToCopyList "PhotoBrushes", SrcDir$, MakePath(DIR(PHOTO),TR_BRUSHES)
				AddSectionFilesToCopyList "PhotoCanvas", SrcDir$, MakePath(DIR(PHOTO),TR_CANVAS)
				AddSectionFilesToCopyList "PhotoColors", SrcDir$, MakePath(DIR(PHOTO),TR_COLORS)
				AddSectionFilesToCopyList "PhotoTiles", SrcDir$, MakePath(DIR(PHOTO),TR_TILES)
				AddSectionFilesToCopyList "PhotoConfig", SrcDir$, MakePath(DIR(MAIN),TR_CONFIG)
				bInstall(PHOTO) = TRUE
			ENDIF
			IF fState% = ALL OR GetListItem( OPTS(PHOTO), 2 ) = "ON" THEN
				AddSectionFilesToCopyList "PhotoHelp", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
			ENDIF
			IF fState% = ALL OR GetListItem( OPTS(PHOTO), 3 ) = "ON" THEN
				AddSectionFilesToCopyList "PhotoSamples", SrcDir$, MakePath(DIR(PHOTO), TR_SAMPLES)
			ENDIF
		ENDIF
			
	CASE MOVE
		bInstall(MOVE) = FALSE
		IF fState% <> NONE THEN
			IF fState% = ALL OR GetListItem( OPTS(MOVE), 1 ) = "ON" THEN
				AddSectionFilesToCopyList "MoveMain", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
				AddSectionFilesToCopyList "MoveLib", SrcDir$, MakePath(DIR(MOVE),TR_LIB)
				AddSectionFilesToCopyList "MoveConfig", SrcDir$, MakePath(DIR(MAIN),TR_CONFIG)
				AddRedistSection "MoveRedist"
				AddSectionFilesToCopyList "MoveRedistWin", SrcDir$, RedistWinDir$
				bInstall(MOVE) = TRUE
			ENDIF
			IF fState% = ALL OR GetListItem( OPTS(MOVE), 2 ) = "ON" THEN
				AddSectionFilesToCopyList "MoveHelp", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
			ENDIF
			IF fState% = ALL OR GetListItem( OPTS(MOVE), 3 ) = "ON" THEN
				AddSectionFilesToCopyList "MoveSamples", SrcDir$, MakePath(DIR(MOVE),TR_SAMPLES)
			ENDIF
		ENDIF

	CASE TRACE
			bInstall(TRACE) = FALSE
			IF fState% = ALL THEN
				AddSectionFilesToCopyList "TraceMain", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
				AddSectionFilesToCopyList "TraceTrace", SrcDir$, DIR(TRACE)
				AddSectionFilesToCopyList "TraceData", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA)
				AddSectionFilesToCopyList "TraceConfig", SrcDir$, MakePath(DIR(MAIN),TR_CONFIG)
				bInstall(TRACE) = TRUE
			ENDIF
			
	CASE MOSAIC
			bInstall(MOSAIC) = FALSE
			IF fState% = ALL THEN
				AddSectionFilesToCopyList "MosaicMain", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
				AddRedistSection "MosaicRedist"
				bInstall(MOSAIC) = TRUE
			ENDIF
			
			
	CASE FILTERS
	
 		DataDir$ =  MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA)
		RedistDir$ = MakePath(DIR(MAIN), TR_REDIST)
		FAddFilters bInstall(DRAW), bInstall(CHART), bInstall(PHOTO), bInstall(MOVE), bInstall(MOSAIC), bInstall(TRACE), SrcDir$, DIR(FILTERS), szWWinDir$, DataDir$,bInstallNet%, RedistDir$
				''Add all necessary import filters
				''Add all the import filters specified using SelectFilters or default
			IF fstate% <> NONE THEN
				IF fstate% = ALL THEN
					SetSymbolValue EXPFILTERLIST1$, "{}"
					SetSymbolValue IMPFILTERLIST1$, "{}"
					MakeListFromSectionKeys EXPFILTERLIST2$, "ExpFilters"
					MakeListFromSectionKeys IMPFILTERLIST2$, "ImpFilters"
					AddRemainingFilters
				ENDIF
				IF IMPFILTERLIST2$ <> "{}" THEN
				FOR i% = 1 TO GetListLength(IMPFILTERLIST2$)
					Filter$ = GetListItem(IMPFILTERLIST2$, i%)
					AddFileToCopyList "", "ImpFiltersMo", Filter$
					AddFileToCopyList "", "ImpFiltersChMo", Filter$
					AddFileToCopyList "", "ImpFiltersMoPhTr", Filter$
					AddFileToCopyList "", "ImpFiltersDrMoTr", Filter$
					AddFileToCopyList "", "ImpFiltersDrMoPhTr", Filter$
					AddFileToCopyList "", "ImpFilters", Filter$
					AddFileToCopyList "Imp", Filter$, Filter$
					Filter$ = ""
				NEXT i%
				ENDIF
				
				''Add all necessary export filters
				''Add all the export filters specified using SelectFilters or default
				IF EXPFILTERLIST2$ <> "{}" THEN	
				FOR i% = 1 TO GetListLength(EXPFILTERLIST2$)
					Filter$ = GetListItem(EXPFILTERLIST2$, i%)
					AddFileToCopyList "", "ExpFiltersPh", Filter$
					AddFileToCopyList "", "ExpFiltersDrPh", Filter$
					AddFileToCopyList "", "ExpFilters", Filter$
					IF Filter$ = "Adobe Illustrator" OR Filter$ = "AutoCAD DXF" THEN
						AddFileToCopyList "Exp", Filter$, Filter$
					ENDIF
					Filter$ = ""	
				NEXT i%
				ENDIF				
			ENDIF
			
	CASE FONTTT
		IF fState% <> NONE THEN
      ''that means fState = SOME or ALL (so let's get the list)
			IF fState% = ALL THEN
				MakeFontList
			ENDIF
			''Add all the fonts specified using SelectFonts (List)
			FOR nIndex% = 1 TO GetListLength(FONTLIST2$)
				Font$ = GetListItem(FONTLIST2$, nIndex%)
				FOR i% = 1 TO GetListLength(szFontSectDisk$) 
					IF IsSectionKeyExist( GetListItem(szFontSectDisk$, i%), Font$) THEN
						AddSectionKeyFileToCopyList GetListItem(szFontSectDisk$, i%), Font$, SrcDir$, DIR(FONTTT)
						EXIT FOR
					ELSEIF IsSectionKeyExist( "DrawFonts", Font$) THEN
						AddSectionKeyFileToCopyList "DrawFonts", Font$, SrcDir$, DIR(FONTTT)
						EXIT FOR
					ENDIF
				NEXT i%
				Font$ = ""
			NEXT nIndex%
		ENDIF
		''The Avante Garde Book Font should be always installed, with DRAW 
		IF bInstall(DRAW) THEN
			AddSectionFilesToCopyList "DrawFonts", SrcDir$, DIR(FONTTT)
		ENDIF
			
	CASE SCANNERS
		IF fState% <> NONE THEN
			AddSectionFilesToCopyList "Twain", SrcDir$, RedistWinDir$
			IF bInstallNet% THEN
				AddSectionFilesToCopyList "TwainScan", SrcDir$, DIR(SCANNERS)
			ELSE
				AddSectionFilesToCopyList "TwainScan", SrcDir$, MakePath(WINDIR$,TR_TWAIN+"\"+TR_COREL)
			ENDIF
			IF fState% = SOME THEN
				IF bDosScanner% THEN
					AddSectionFilesToCopyList "ZSTwainScan", SrcDir$, DIR(SCANNERS) 
					Section$ = GetListItem(SCANNERSECTION$, 1)
					AddSectionFilesToCopyList Section$, SrcDir$, DIR(SCANNERS) 
				ENDIF
				IF bTwainScanner% THEN
					Section$ = GetListItem(SCANNERSECTION$, 1)
					AddSectionFilesToCopyList Section$, SrcDir$, DIR(SCANNERS) 
				ENDIF
			ENDIF
			IF fState% = ALL AND bInstallNet% THEN
				AddSectionFilesToCopyList "ZSTwainScan", SrcDir$, DIR(SCANNERS) 
				AddSectionFilesToCopyList "Canon", SrcDir$, DIR(SCANNERS) 
				AddSectionFilesToCopyList "Epson", SrcDir$, DIR(SCANNERS) 
				AddSectionFilesToCopyList "HPScaner", SrcDir$, DIR(SCANNERS) 
				AddSectionFilesToCopyList "Logitech", SrcDir$, DIR(SCANNERS) 
				AddSectionFilesToCopyList "Microtek", SrcDir$, DIR(SCANNERS) 
			ENDIF
		ENDIF
			
		 
	CASE MAIN
		
		bInstallApp%=FALSE
		FOR i% = DRAW TO MOSAIC STEP 1
			IF bInstall(i%) THEN
				bInstallApp% = TRUE
			ENDIF
		NEXT i%
		IF bInstallApp% THEN
			'' So we have an App to install, so we can create the main directory
				
			IF bInstallNet% THEN
				'' Add net install files
				FOR i% = 1 TO NUMGROUPS STEP 1
					IF afState(i%) <> NONE THEN
						AddSectionFilesToCopyList "NetInf", SrcDir$, DIR(i%)
					ENDIF
				NEXT i%
				AddSectionFilesToCopyList "NetInst", SrcDir$, MakePath(DIR(MAIN),TR_SETUP)
				AddSectionFilesToCopyList "NetInf", SrcDir$, MakePath(DIR(MAIN),TR_SETUP)
				AddSectionFilesToCopyList "NetInf", SrcDir$, MakePath(DIR(MAIN),TR_CONFIG)
				AddSectionFilesToCopyList "NetInf", SrcDir$, MakePath(DIR(MAIN),TR_REDIST)
				AddSectionFilesToCopyList "NetInf", SrcDir$, MakePath(DIR(MAIN),TR_CUSTOM)
				AddSectionFilesToCopyList "NetInf", SrcDir$, MakePath(DIR(MAIN),TR_SYMBOLS)
				AddSectionFilesToCopyList "NetInf", SrcDir$, MakePath(DIR(PHOTO),TR_COLORS)
			ENDIF
			
			AddSectionFilesToCopyList "Main", SrcDir$, DIR(MAIN)
			AddSectionFilesToCopyList "CommonDLL", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS)
			AddSectionFilesToCopyList "CommonConfig", SrcDir$, MakePath(DIR(MAIN),TR_CONFIG)
			AddSectionFilesToCopyList "Custom", SrcDir$, MakePath(DIR(MAIN),TR_CUSTOM)
			AddSectionFilesToCopyList "ProgramData", SrcDir$, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA)
			AddRedistSection "CommonRedist"
			
		 
		'' Adding the required common DLLs
		'$IFNDEF INSTALLCD
			IF bInstall(CHART) OR bInstallClipart% THEN
				AddSectionFilesToCopyList "ClipartVectors", SrcDir$, MakePath(DIR(MAIN),TR_CLIPART)
			ENDIF
		'$ENDIF
				
		ENDIF ''bInstallApp
			
	END SELECT
	
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:
'**       DRAW, CHART, SHOW, PHOTO, MOVE, TRACE, MOSAIC, FILTERS, FONTTT, MAIN
'** Returns:
'**     none.
'*************************************************************************
SUB RecalcOptFiles (ftype%) STATIC
	ClearCopyList
	AddOptFilesToCopyList ftype%
	
	FRecalcOptFiles ftype%, aszNEEDS(ftype%)
		
END SUB


'**
'** Purpose:
'**     Recalculates disk space and sets option status info according
'**     to the current destination path.
'** Arguments: Type%: Passed to RecalcGroup
'**     none.
'** Returns:
'**     none.
'*************************************************************************
SUB RecalcPath STATIC

	FOR i% = 1 TO NUMGROUPS STEP 1
		RecalcOptFiles i%
	NEXT i%
END SUB


'**
'** Purpose:
'**     Sets drive status info according to latest disk space calcs.
'**     Checks that enough space is available on all drives.
'** Arguments:
'**     none.
'** Returns:
'**     none.
'*************************************************************************
SUB SetDriveStatus STATIC
	
	DIM alCosts AS POINTER TO LONG
	NoOfDrives% = GetListLength(DrivesList$)	
	ALLOCATE alCosts, NoOfDrives%
	
	''Calculate total costs for each drive
	FOR i% = 0 TO NoOfDrives%-1 STEP 1
		alCosts[i%] = 0
	NEXT i%
	
	wdrive% = ASC(UCASE$(WINDRIVE$)) - ASC("A") 	
	FOR i% = 0 TO NoOfDrives%-1
		ndrive% = ASC(GetListItem(DrivesList$, i%+1)) - ASC("A") 
		FOR j%= 1 TO NUMGROUPS
			alCosts[i%] = alCosts[i%] + VAL(GetListItem(aszNEEDS(j%), ndrive%+1))
		NEXT j%
		IF wdrive% = ndrive% THEN '' we have the window drive
			alCosts[i%] = alCosts[i%]+ 1350 * GetListLength(FONTLIST2$)
		ENDIF
	NEXT i%
	
	''Store the costs and free space for the first five drives used
	j% = 0
	bTooBig% = FALSE
	FOR i% = 0 TO NoOfDrives%-1 STEP 1
		if alCosts[i%] > 0 THEN
			j% = j% + 1
			drive$ = GetListItem(DrivesList$, i%+1) 
			free& = GetFreeSpaceForDrive(drive$)
			IF free& < alCosts[i%] THEN
				bTooBig% = TRUE
			ENDIF
			IF j% < 6 THEN
				ReplaceListItem DRIVETEXT$, j%*3-2, drive$ + ":"
				ReplaceListItem DRIVETEXT$, j%*3-1, STR$(alCosts[i%] / 1024) + " K"
				ReplaceListItem DRIVETEXT$, j%*3, STR$(free& / 1024) + " K"
			ENDIF
			drive=""
		ENDIF
	NEXT i%
	''wipe clean all remaining directory information
	FOR i% = j%*3+1 TO 15 STEP 1
		ReplaceListItem DRIVETEXT$, i%, ""
	NEXT i%
	DEALLOCATE alCosts

END SUB


'**
'** Purpose:
'**     Removes the optional trailing "\"
'** Arguments:
'**     szDir$  - full directory path (with optional ending "\")
'** Returns:
'**     szDir$ without a trailing "\"
'*************************************************************************
FUNCTION MakeDir (szDir$) STATIC AS STRING
	IF szDir$ <> "" THEN
		IF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
			MakeDir = MID$( szDir$, 1, LEN(szDir$) - 1 )
		ELSE
			MakeDir = szDir$
		ENDIF
	ELSE
		MakeDir = szDir$
	ENDIF
END FUNCTION

'** Add Redistributable files to the correct directory(s) in the copy list
'*************************************************************************
SUB AddRedistSection( szSection$) STATIC
	IF bWindowsIsNetworked% OR bInstallNet% = FALSE THEN
		'' Copy the redistributable files and dlls to windir or winsysdir
		AddSectionFilesToCopyList szSection$, SrcDir$, szWWinDir$
	ENDIF
	IF bInstallNet% THEN
		'' Store the redistributable files in REDIST until user installs
		AddSectionFilesToCopyList szSection$, SrcDir$, MakePath(DIR(MAIN),TR_REDIST)
	ENDIF
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
	MakePath = MakeDir(szDir$) + "\" + szFile$
END FUNCTION


'** This sub converts the symbol "InstallDirs" into the DIR array
'** and the symbol "InstallState" into the afState array, 
'** recalculating disk usage if anything has changed.
'** NOTE: this a only a simulated subroutine because we want to be
'**       able to GOSUB BADPATH from inside it.
'*************************************************************************
SetDirFromSymbol:
	'' Convert "InstallState" into the afState array
	bRecalcMain% = FALSE
	FOR i% = 1 TO NUMCUST STEP 1
		fNewState% = ASC( GetListItem("InstallState",i%) ) - ASC("1") + 1
		IF fNewState% <> afState(i%) THEN
			afState(i%) = fNewState%
			RecalcOptFiles i%
			IF fNewState% <> 2 THEN
				bRecalcMain% = TRUE
			ENDIF
		ENDIF
	NEXT i%
	IF bRecalcMain% THEN
		RecalcOptFiles MAIN
	ENDIF
	
	'' Convert "InstallDir" into the DIR array
		szList$ = "InstallDirs"
		bBadPath% = FALSE
		FOR nIndex% =1 TO GetListLength(szList$)
			szDir$ = RTRIM$(LTRIM$(GetListItem(szList$, nIndex%)))
			'' If the directory is not writable, tell the user and don't update it.
			IF szDir$ = "" OR IsDirWritable( szDir$ ) = 0 THEN
				Dialog% = ERRORBADPATH
				GOSUB INFO
				bBadPath% = TRUE
				RETURN
			ENDIF
			'' If the directory has changed - recalculate disk usage
			IF DIR(nIndex%) <> szDir$ THEN
				DIR(nIndex%) = szDir$
				RecalcOptFiles nIndex%
			ENDIF
		NEXT nIndex%	
	szDir$ = ""
	szList$ = ""
RETURN

'** This sub sets all files to load - sets directory structure to default
'*************************************************************************
SUB FullInstall STATIC

	DIR(MAIN) = DEST$
	SetDirectories
	
	''Sets options to all on
	FOR i%=1 TO 3
		AddListItem OPTS(CHART), "ON"
		AddListItem OPTS(PHOTO), "ON"
		AddListItem OPTS(MOVE), "ON"
		AddListItem OPTS(SHOW), "ON"
		AddListItem OPTS(DRAW), "ON"
	NEXT i%
		AddListItem OPTS(DRAW), "ON"
	'$IFNDEF INSTALLCD
		AddListItem OPTS(DRAW), "ON"
	'$ENDIF
	
	''Set all sections to install
	FOR i% = DRAW TO NUMGROUPS STEP 1
		afState(i%) = ALL
	NEXT i%
		afState(SCANNERS) = NONE

	''Prepare lists for Customized selection of filters, fonts and symbols
	SetSymbolValue IMPFILTERLIST1$, "{}"
	SetSymbolValue EXPFILTERLIST1$, "{}"
	SetSymbolValue SYMBOLLIST1$, "{}"
	SetSymbolValue FONTLIST1$, "{}"

	MakeListFromSectionKeys IMPFILTERLIST2$, "ImpFilters"
	MakeListFromSectionKeys EXPFILTERLIST2$, "ExpFilters"
	MakeListFromSectionKeys SYMBOLLIST2$, "WFN"
	MakeFontList
END SUB


'** Set the subdirectories to their default values.
'*************************************************************************
SUB SetDirectories STATIC
	DIR(DRAW) 		= MakePath( DIR(MAIN), TR_DRAW )
	DIR(CHART) 		= MakePath( DIR(MAIN), TR_CHART )
	DIR(SHOW) 		= MakePath( DIR(MAIN), TR_SHOW )
	DIR(PHOTO) 		= MakePath( DIR(MAIN), TR_PHOTOPNT )
	DIR(MOVE) 		= MakePath( DIR(MAIN), TR_MOVE )
	DIR(TRACE) 		= MakePath( DIR(MAIN), TR_TRACE )
	DIR(MOSAIC) 	= MakePath( DIR(MAIN), TR_PROGRAMS )
	SetFontAndScannerDir
	DIR(SCANNERS)	= MakeDir(szScannerDir$)
	DIR(FILTERS) 	= MakePath( DIR(MAIN), TR_PROGRAMS )
	DIR(FONTTT) 	= MakeDir(szFontDir$)
	szFontDir$ = ""
END SUB


'** Make sure that the long wait dialog is displayed and the hourglass cursor
'** are being used
'*************************************************************************
SUB WaitOnBig STATIC
	IF nWaiting% = 0 THEN
		CursorSave% = ShowWaitCursor()
	ENDIF
	IF nWaiting% <> 2 THEN
		sz$ = UIStartDlg("mscuistf.dll", WAIT, "FModelessDlgProc", 0, "")
	ENDIF
	nWaiting% = 2
END SUB


'** Make sure that the hourglass cursor is being used
'*************************************************************************
SUB WaitOn STATIC
	IF nWaiting% = 0 THEN
		CursorSave% = ShowWaitCursor()
		nWaiting% = 1
	ENDIF
END SUB


'** Remove the long wait dialog if it is being displayed and reset the cursor
'** back to normal if it was set to the hourglass icon
'*************************************************************************
SUB WaitOff STATIC
	IF nWaiting% = 2 THEN
		UIPop 1
	ENDIF
	IF nWaiting% <> 0 THEN
		RestoreCursor CursorSave%
	ENDIF
	nWaiting% = 0
END SUB


'** Set the directories for the fonts and redistributable files
'*************************************************************************
SUB SetFontAndScannerDir STATIC
	IF bInstallNet% THEN
		szFontDir$ = MakePath( DIR(MAIN), TR_TTF )
		szScannerDir$ = MakePath( DIR(MAIN), TR_SCANNERS)
		szWWinDir$ = WINSYSDIR$
	ELSE
		IF bWindowsIsNetworked% THEN
			szFontDir$ = WINDIR$
			szWWinDir$ = WINDIR$
		ELSE
			szFontDir$ = WINSYSDIR$
			szWWinDir$ = WINSYSDIR$
		ENDIF
		szScannerDir$ = MakePath(WINDIR$,TR_TWAIN+"\"+TR_COREL)
	ENDIF
END SUB


'** Wrapper function - should reduce size of code segment.
'**
'** FileChangeString replaces szString1$ in szFile1$ with szString2$.
'** szFile2$ is a temporary file name.
'*************************************************************************
SUB	WrapFileChangeString( szFile1$, szFile2$, szString1$, szString2$ ) STATIC
	FileChangeString szFile1$, szFile2$, szString1$, szString2$
END SUB


'** Wrapper function - should reduce size of code segment.
'**
'** CommentIniSection checks to see whether or not the files mentioned in
'** szSection$ can be found in directory szPath$. If not, it sticks a ';'
'** in front of that line of the ini file. Otherwise it makes sure there
'** is not semi-colon commenting out that line.
'** Note: this function is heavily dependent on the format of coreldrw.ini
'*************************************************************************
SUB	WrapCommentIniSection( szFileName$, szTempFile$, szSection$, szPath$ ) STATIC
	CommentIniSection szFileName$, szTempFile$, szSection$, szPath$
END SUB


'** If the second file does not exist, backup szFile1$ as szFile2$
'*************************************************************************
SUB CheckBackupFile( szFile1$, szFile2$ ) STATIC
	IF DoesFileExist(szFile2$,femExists) = 0 AND DoesFileExist(szFile1$,femExists) THEN
		CopyFile szFile1$, szFile2$, cmoNone, 0
	ENDIF
END SUB

'*************************************************************************
FUNCTION CreateProgmanItem (szGroup$, szItem$, szCmd$, szOther$, cmo%) STATIC AS INTEGER
  szItemNew$ = szItem$
  IF szOther$ <> "" THEN
    szItemNew$ = szItem$ + "," + szOther$
  END IF

  IF FCreateProgManItem(szGroup$, szItemNew$, szCmd$, cmo%) = 0 THEN
		CreateProgmanItem = 1
	ELSE
		CreateProgmanItem = 0
  END IF
	szItemNew$ = ""
END FUNCTION


'** This sub Add filters to the user choice list.
'** It add the filters which will not be installed by the selected application
'*************************************************************************
SUB AddRemainingFilters STATIC
   FAddRemainingFilters bInstall(DRAW), bInstall(CHART), bInstall(PHOTO), bInstall(MOSAIC), bInstall(TRACE)
END SUB

'** This sub Add fonts to the user choice list, if he didn't choose the group.
'** It add the fonts which will not be installed by the unsellected list
'*************************************************************************
SUB MakeFontList STATIC
	
	SetSymbolValue FONTLIST1$, "{}"
	SetSymbolValue FONTLIST2$, "{}"
	FMakeFontList bInstall(DRAW)
			
END SUB


'***********************************************************************
'***********************************************************************
'**** Add Filter (If Exist in Section) to copy list ********************
'***********************************************************************
SUB AddFileToCopyList(AppendSect$, Section$, FilterName$) STATIC
		Destination$ = DIR(FILTERS)
		IF AppendSect$ = "Imp" AND Section$ = "Kodak Photo-CD" THEN
			IF bInstallNet% THEN
				AddSectionFilesToCopyList "ImpKodak Photo-CD", SrcDir$, MakePath(DIR(MAIN),TR_REDIST)
			ENDIF
			IF bWindowsIsNetworked% OR bInstallNet% = FALSE THEN
				Destination$ = szWWinDir$
			ENDIF
		ELSEIF (Section$ = "Adobe Illustrator" OR Section$ = "AutoCAD DXF" OR Section$ = "EPS (Thumbnail)") THEN
				Destination$ = MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA)
		ENDIF
		FAddFileToCopyList AppendSect$, Section$, FilterName$, SrcDir$, Destination$
''		Destination$ = ""
END SUB

