'' $Keywords: draw.mst 1.22 04Aug93 09:16am$ $nokeywords$
'**************************************************************************
'*                       CorelTools setup script
'**************************************************************************
''    Date         Name                Reason
''-------------------------------------------------------------------------
'' Feb 25 1992  Randall Mack    Modified from sample2.mst provided with
''                              Windows SDK 3.1 Beta.
'' Feb 5	1993	Ibrahim Sallam	Modified for Draw 4.0

'' The following definitions is to limit the install program in this stage
'' till the rest of application finished.

'$INCLUDE 'setupapi.inc'

''C functions
DECLARE SUB				InitializeInstall LIB "mscuistf.dll" (hInstance%, hMainWind% )
DECLARE SUB				ShutDownInstall LIB "mscuistf.dll"
DECLARE SUB				RegisterFont LIB "mscuistf.dll" (szFOTName$, szTTFName$) 
DECLARE SUB				FileChangeString LIB "mscuistf.dll" (szFile1$, szFile2$, szString1$, szString2$)
DECLARE SUB				FRecalcOptFiles LIB "mscuistf.dll" (iType%, szNeeds$)
DECLARE FUNCTION	FIsDrawExist LIB "mscuistf.dll" (szFileName$, szDest$) AS INTEGER
DECLARE FUNCTION	IsSectionKeyExist LIB "mscuistf.dll" (szSectionName$, szKeyName$) AS INTEGER
DECLARE SUB 			FAddFileToCopyList LIB "mscuistf.dll" (AppendSect$, Section$, FilterName$, SourceDir$, FiltersDir$) 
DECLARE SUB				CommentIniSection LIB "mscuistf.dll" (szFileName$, szTempFile$, szSection$, szPath$ )
DECLARE FUNCTION	GetFilenameFromPath LIB "mscuistf.dll" (szPath$) AS INTEGER
DECLARE FUNCTION	IsTTFEnabled LIB "mscuistf.dll" AS INTEGER
DECLARE SUB				InitScannerSelection LIB "mscuistf.dll" 
DECLARE FUNCTION	FGetScannerLine LIB "mscuistf.dll" (szScannerDir$) AS INTEGER
DECLARE SUB				CloseScannerSelection LIB "mscuistf.dll" 
DECLARE FUNCTION	FModifyFile LIB "mscuistf.dll" (szFileName$, szList$, szWhere$) AS INTEGER
DECLARE FUNCTION	IsWinForWorkgroups LIB "mscuistf.dll" AS INTEGER
DECLARE FUNCTION	VerifyNumber LIB "mscuistf.dll" (szSerialNumber$) AS INTEGER
DECLARE SUB       MakeFontSectList LIB "mscuistf.dll"
DECLARE SUB       FMakeFontList LIB "mscuistf.dll" (DRAW%)
DECLARE SUB       FAddRemainingFilters LIB "mscuistf.dll" (Draw%, Chart%, Photo%, Mosaic%, Trace%)
DECLARE SUB 			FAddFilters LIB "mscuistf.dll" (DRAW%, CHART%, PHOTO%, MOVE%, MOSAIC%, TRACE%, SrcDir$, FILTERSDIR$, WWinDir$, DataDir$, bInstallNet%, RedistDir$)
DECLARE FUNCTION 	FGetBootDrive LIB "mscuistf.dll" AS INTEGER

'$INCLUDE 'setupvar.inc'

''Strings for loading string resources
GLOBAL szString$
CONST	 STRINGLEN =	128
szString$ = string$( STRINGLEN+1, 32 )

''setup main window
CONST LOGO							= 9100			''must match the constant in dialogs.h
SetTitle TR_TITLE
SetBitmap "mscuistf.dll", LOGO
InitializeInstall hinstFrame(), HwndFrame()		''corel style buttons; max window

'$INCLUDE 'msdetect.inc'

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

''Dialog ID's
''Note: These constants MUST match the constants in dialogs.h
CONST WELCOME    				= 9900
CONST ASKQUIT    				= 9901
CONST DESTPATH   				= 9902
CONST ERROREXITFAILURE	= 9903
CONST EXITQUIT   				= 9904
CONST EXITSUCCESS				= 9905
CONST OPTIONS    				= 9906
CONST TOOBIG     				= 9908
CONST ERRORBADPATH   		= 9909
CONST CUSTCHART					= 9911
CONST CUSTSHOW					= 9912
CONST CUSTPHOTO					= 9913
CONST CUSTMOVE					= 9914
CONST SELECTFILTERS			= 9916
CONST SELECTFONTSYM			= 9917
CONST SELECTFONTTT			= 9918
CONST SELECTFONTTTCD		=	9821
CONST WAIT							= 9919
CONST ABOUT							= 9920
CONST ASKINSTALL				= 9922
CONST WARNINGDESTPATH		= 9923
CONST CUSTTTFONT				= 9924
CONST BILLBOARD					= 9926
CONST CDROMCUSTDRAW			= 9927
CONST FLOPPYCUSTDRAW  	= 9928
CONST UPDATEHELP   		  = 9929
CONST UPDATEAUTOEXEC		= 9930
CONST UPDATEAUTOEXECFORSHARE		= 9931
CONST UPDATECONFIG			= 9934
CONST WAITREGISTER			= 9932
CONST BADGROUP					= 9933
CONST SUCCESS						= 9938
CONST WAITCONFIGER			= 9939
CONST WINREADONLY				= 9943
CONST NETINSTWELCOME		= 9944
CONST NETADDITEMFAILED	= 9949
CONST NETADMINABOUT			= 9950
CONST WELCOMEHELP				= 9800
CONST OPTIONSHELP				= 9801
CONST DESTPATHHELP   		= 9802
CONST CUSTINSTHELP  		= 9803
CONST CUSTINST2HELP 		= 9804
CONST SELECTHELP    		= 9806
CONST ASKINSTALLHELP		= 9808
CONST CUSTINST1					= 9813
CONST CUSTINST2					= 9814
CONST CUSTSCAN          = 9815
CONST CUSTSCANHELP      = 9816
CONST REGISTRATION      = 9817
CONST REGISTRATIONBADNAME = 9818
CONST REGISTRATIONBADSN = 9819
CONST TTF100ANDMORE     = 9820
CONST BILLBOARD1				= 9990
CONST MOREFONTS           = 9824
CONST INSTALLINGDRAW      = 9830

''Constants representing each line in the custinst dialog
CONST DRAW  		= 1
CONST CHART 		= 2
CONST SHOW			= 3
CONST PHOTO			= 4
CONST MOVE			= 5
CONST TRACE			= 6
CONST MOSAIC		= 7
CONST SCANNERS  = 8
CONST FILTERS		= 9			''Does not have custom dialog
CONST FONTTT		= 10
CONST NUMCUST	  = FONTTT
CONST MAIN			= NUMCUST + 1
CONST NUMGROUPS	= MAIN

CONST FALSE	= 0
CONST TRUE	= 1

'' Set this constant to the type of install interested in.
'$DEFINE INSTALLCD		''When this is set, Draw will install off cd-rom

'' used as values for afState(NUMCUST) array.
CONST ALL		= 1
CONST	SOME	= 2
CONST	NONE	= 3

'' set 'customize' variables
'' Customized installation settings
GLOBAL OPTS(MOVE) AS STRING
OPTS(DRAW)		= "DrawOpt"
OPTS(CHART)		= "ChartOpt"
OPTS(SHOW)		= "ShowOpt"
OPTS(PHOTO)		= "PhotoOpt"
OPTS(MOVE)		= "MoveOpt"

''lists of reference keys for filters, fonts and symbols. 1 = install, 2 = don't
GLOBAL IMPFILTERLIST1$
IMPFILTERLIST1$	= "ImportFilterList1"
GLOBAL IMPFILTERLIST2$
IMPFILTERLIST2$	= "ImportFilterList2"
GLOBAL EXPFILTERLIST1$
EXPFILTERLIST1$	= "ExportFilterList1"
GLOBAL EXPFILTERLIST2$
EXPFILTERLIST2$	= "ExportFilterList2"
GLOBAL FONTLIST1$
FONTLIST1$		= "FontList1"
GLOBAL FONTLIST2$
FONTLIST2$		= "FontList2"
GLOBAL SYMBOLLIST1$
SYMBOLLIST1$	= "SymbolList1"
GLOBAL SYMBOLLIST2$
SYMBOLLIST2$	= "SymbolList2"

'' Scanners STUFF
GLOBAL CONFIGLINE$
CONFIGLINE$ = "ConfigLine"
GLOBAL AUTOEXECLINE$
AUTOEXECLINE$ = "AutoexecLine"
GLOBAL SCANNERSECTION$
SCANNERSECTION$ = "ScannerSection"


'' Filters STUFF
'' Actually these are not filters stuff, they are flags used in the filter section
GLOBAL bInstall(MOSAIC) AS INTEGER
GLOBAL bInstallClipart%
''bInstallClipart%=FALSE


''information text for custom installation window
GLOBAL STATUSTEXT$
STATUSTEXT$  = "StatusItemsText"
GLOBAL DRIVETEXT$
DRIVETEXT$   = "DriveStatusText"
GLOBAL DrivesList$			''experemental variable for the drives list
DrivesList$ = "DrivesList"
GLOBAL TempList$				'' Used for Temp lists
TempList$ = "TempList"

''used as a parm to GetCopyListCost only
GLOBAL EXTRACOSTS$
EXTRACOSTS$ = "ExtraCosts"
GLOBAL bTooBig%
bTooBig% = FALSE
GLOBAL bBadPath%
bBadPath% = FALSE
GLOBAL bBack%
bBack% = FALSE
GLOBAL bFullInstall%		'' TRUE ==> user went through Full Install Option

GLOBAL bAutoexecModified% '' TRUE ==> Config.sys has beed modified.
bAutoexecModified% = FALSE

GLOBAL bInstallNet%			'' Are we installing a network version?
GLOBAL bDosScanner%	'' Did we install any Scanners? 
bDosScanner% = FALSE
GLOBAL bTwainScanner%	'' Did we install any Scanners? 
bTwainScanner% = FALSE

GLOBAL bInstallApp%	'' Are we going to install any APP, so we can create
												'' Programs, & config dir. and update the win.ini

''list of sections (1..NUMGROUPS)
GLOBAL afState(NUMCUST) AS INTEGER		''list of selections for main options
GLOBAL DIR(NUMGROUPS) AS STRING        ''list of directories for main options
GLOBAL NUM(3) AS STRING								''string representations of 1 .. 3
''CustInst list of symbol names - each is a list of 26 numbers corresponding
''  to the space required on that numbered drive for the files in the
''  corresponding group
GLOBAL aszNEEDS(NUMGROUPS) AS STRING

GLOBAL WINDIR$			''Windows directory.
GLOBAL WINSYSDIR$		''Windows directory.
GLOBAL WINDRIVE$		''Windows drive letter.
GLOBAL bWindowsIsNetworked%
GLOBAL bWindowsForWorkgroups%
GLOBAL DEST$    		''destination directory.
GLOBAL szFontDir$		''directory for .ttf fonts
GLOBAL szScannerDir$''directory for scanner files
GLOBAL szWWinDir$		''Writable Windows directory

GLOBAL szFontSectDisk$
szFontSectDisk$ = "FontSectDisk"

GLOBAL szUserName$			''UserName for registration
GLOBAL szSerialNumber$	''SerialNumber for registration

GLOBAL TOOLGROUP$					'' Group in which tools are to be installed
''GLOBAL aszGroups(MOSAIC) AS STRING	'' Custom progman groups

''Windows version numbers
GLOBAL WinMinor%

''Variables to fake subroutines with parameters
GLOBAL szFlist1a$
GLOBAL szFlist1b$
GLOBAL szFlist2a$
GLOBAL szFlist2b$
GLOBAL Dialog%
GLOBAL SelectType%
GLOBAL szOptions$
GLOBAL szTempVar$

''TRUE => must do a global recalculation after GetPath - starts TRUE
GLOBAL bRecalc%

''Globals for WaitOn and WaitOff
GLOBAL nWaiting%
GLOBAL CursorSave%

''GLOBAL bPathAltered%	'' If set then autoexec.bat has been changed
GLOBAL SrcDir$				'' Directory where files can be found
SrcDir$ = GetSymbolValue("STF_SRCDIR")

''local MSTest functions
DECLARE SUB WaitOnBig
DECLARE SUB WaitOn
DECLARE SUB WaitOff
DECLARE SUB SetDirectories
DECLARE SUB FullInstall
DECLARE SUB AddOptFilesToCopyList( ftype% )
DECLARE SUB RecalcOptFiles( fType% )
DECLARE SUB RecalcPath
DECLARE SUB SetDriveStatus
DECLARE SUB SetFontAndScannerDir
DECLARE SUB	WrapFileChangeString( szFile1$, szFile2$, szString1$, szString2$ )
DECLARE SUB	WrapCommentIniSection( szFileName$, szTempFile$, szSection$, szPath$ )
DECLARE	SUB	CheckBackupFile( szFile1$, szFile2$ )
DECLARE FUNCTION CreateProgmanItem (szGroup$, szItem$, szCmd$, szOther$, cmo%) AS INTEGER
DECLARE FUNCTION MakePath( szDir$, szFile$ ) AS STRING
DECLARE FUNCTION MakeDir( szDir$ ) AS STRING
DECLARE SUB AddRedistSection( szSection$)
DECLARE SUB AddRemainingFilters
DECLARE SUB MakeFontList
DECLARE SUB AddFileToCopyList(AppendSect$, Section$, FilterName$) 


INIT:
	'' set waiting cursor
	nWaiting% = 0
	WaitOn
	
 	'' Determine whether or not we are installing as a network administrator.
	'' If we are, modify the copy of the .inf file to force files to be copied
	'' as readonly.
	bInstallNet% = FALSE
	AddListItem "NetAdmin","OFF"
	IF GetSymbolValue("STF_MODE") = "ADMIN" THEN
		bInstallNet% = TRUE
		'' set the .inf readonly flag to true
		szDir$ = GetSymbolValue("STF_CWDDIR")
		WrapFileChangeString MakePath(szDir$,"draw.inf"), MakePath(szDir$,"___temp_"), """STF_READONLY""   = """"", """STF_READONLY""   = ""YES"""
		szDir$ = ""
		ReplaceListItem "NetAdmin", 1, "ON"
	ENDIF

	''Set default directory names
	WINDIR$ = GetWindowsDir
	WINSYSDIR$ = GetWindowsSysDir
	WINDRIVE$ = MID$(WINDIR$, 1, 1)
	bWindowsIsNetworked% = IsDriveNetwork( MID$(WINSYSDIR$,1,1) )
	bWindowsForWorkgroups% = IsWinForWorkgroups
	DEST$ = WINDRIVE$ + ":\"+TR_CORELDRW
	OpenLogfile MakePath(WINDIR$, TR_LOGFILE), 0
	DIR(MAIN) = DEST$
	SetDirectories
	
	'$IFDEF INSTALLCD
		WriteToLogFile TR_INSTALLCD
	'$ELSE
		WriteToLogFile TR_INSTALLFLOPPY
	'$ENDIF
	IF bInstallNet% THEN
		WriteToLogFile TR_INSTALLNETADMIN
	ENDIF
	IF bWindowsIsNetworked% THEN
		WriteToLogFile TR_NETWINDOWS
	ENDIF
	IF bWindowsForWorkgroups% THEN
		WriteToLogFile TR_WORKGROUPWINDOWS
	ENDIF
	
 	'' Quit if installing a network version and windows is readonly on net
	IF bWindowsIsNetworked% AND bInstallNet% AND IsDirWritable(WINSYSDIR$) = 0 THEN
		Dialog% = WINREADONLY
		GOSUB INFO
		ERR = STFERR
		GOTO QUIT
	ENDIF

	''find and read .inf file
	ReadInfFile GetSymbolValue("STF_CWDDIR") + "draw.INF"

	FOR i% = 1 TO MAIN
 		AddListItem STATUSTEXT$, ""
	NEXT i%
	''We have 15 DRIVETEXT variables defined for 5 drives only
	FOR i% = 1 TO 15
		AddListItem DRIVETEXT$, ""
	NEXT i%
	
	''Disk cost list symbols
	FOR i% = 1 TO NUMGROUPS STEP 1
		aszNEEDS(i%)		= "DrawNeeds" + STR$(i%)
	NEXT i%
	
	''basic initialization
	NUM(1) = "1"
	NUM(2) = "2"
	NUM(3) = "3"
	''Get Drives List
	GetValidDrivesList(DrivesList$)
'''' The Drives List will define the length of the EXTRACOSTS$
	FOR i%=1 TO GetListLength(DrivesList$)
		''Disk cost list symbols
		FOR j% = DRAW TO NUMGROUPS 
			AddListItem aszNEEDS(j%), "0"
		NEXT j%
	NEXT i%
	
      MakeFontSectList
		
	''Set windows version - for use with installing windows 3.1 DLL's
	'' 25Feb93: We wont install 4.0 on Win3.0.
	'' 16Mar93: The following Check is not working YET.
''	WinMajor% = GetWindowsMajorVersion
	WinMinor% = GetWindowsMinorVersion
	
	''set the default progman group to put everything in
	TOOLGROUP$	= TR_TOOLGROUP
	
'' Put up the Welcome dialog
WELCOME:
	WaitOff
	IF bInstallNet% THEN
		Dialog% = NETINSTWELCOME
	ELSE
		Dialog% = WELCOME
	ENDIF
	sz$ = UIStartDlg( "mscuistf.dll", Dialog%, "FInfoDlgProc", WELCOMEHELP, "FHelpDlgProc" )
	SELECT CASE sz$
	CASE "CONTINUE"
		UIPop 1
	CASE "ABOUT"
		IF bInstallNet% THEN
			Dialog% = NETADMINABOUT
		ELSE
			Dialog% = ABOUT
		ENDIF
		GOSUB INFO
		GOTO WELCOME
	CASE "REACTIVATE"
		GOTO WELCOME
	CASE ELSE
		GOSUB ASKQUIT
		GOTO WELCOME
	END SELECT

''Before we give him OPTIONs let's get the user name and his serial number.
REGISTER:
	AddListItem "EditText", ""
	AddListItem "EditText", ""
REGISTER1:
	sz$ = UIStartDlg("mscuistf.dll", REGISTRATION, "FMultiEditDlgProc", 0, "")
	SELECT CASE sz$
	CASE "CONTINUE"
		WaitOn
		szUserName$ = RTRIM$(LTRIM$(GetListItem("EditText", 1)))
		szSerialNumber$ = RTRIM$(LTRIM$(GetListItem("EditText", 2)))
		IF szUserName$ = "" THEN
			Dialog% = REGISTRATIONBADNAME
			GOSUB INFO
			GOTO REGISTER1
		ENDIF
		IF VerifyNumber(szSerialNumber$) = FALSE THEN
			''Dialog% = REGISTRATIONBADSN
			''GOSUB INFO
			''GOTO REGISTER1
		ENDIF
			
	CASE "REACTIVATE"
		GOTO REGISTER1
	CASE ELSE
		GOSUB ASKQUIT
		GOTO REGISTER1
	END SELECT
	UIPop 1
RemoveSymbol "EditText"

'' fall through from WELCOME
'' Allow the user to select between full, minimal and custom installation
'' OOPS, we removed minimum, so it's only FULL or CUSTOM.
OPTIONS:
	WaitOff
	bFullInstall% = FALSE		
	''At least one recalculation must be made to determine that everything fits
	bRecalc% = TRUE
	sz$ = UIStartDlg( "mscuistf.dll", OPTIONS, "FButtonsDlgProc", OPTIONSHELP, "FHelpDlgProc" )
	SELECT CASE sz$
	CASE "F"
		bFullInstall = TRUE
		WriteToLogfile TR_FULLINSTALL
	CASE "C"
		WriteToLogfile TR_CUSTOMINSTALL
	CASE "REACTIVATE"
		GOTO OPTIONS
	CASE ELSE
		GOSUB ASKQUIT
		GOTO OPTIONS
	END SELECT
	UIPop 1
	
 	''if not quitting the user will go to installation which is either FULL or
	''CUSTOM, both has same start.
	FullInstall
	GOSUB GETPATH
	IF bBack% THEN
		GOTO OPTIONS
	ENDIF
	GOSUB CUSTINST
	IF bBack% THEN
		GOTO OPTIONS
	ENDIF

'' fall through from OPTIONS
'' Do the installation using afState, OPTS(DRAW) .. OPTS(MOVE), etc. to
'' indicate which files should be installed.
INSTALL:
	WaitOn
	''Make sure there is enough space for CorelDRAW!
		WaitOnBig
		bRecalc% = FALSE
		RecalcPath 
		SetDriveStatus
	IF bTooBig% THEN
		Dialog% = TOOBIG
		GOSUB INFO
		GOTO OPTIONS
	ENDIF
	
	ClearCopyList
	''Create all directories needed and assign all the files to copy
	FOR i% = 1 TO NUMGROUPS STEP 1
			AddOptFilesToCopyList i%
	NEXT i%
	
  IF bInstallNet% = FALSE THEN
		'' backup files to *.cor - do not overwrite
		CheckBackupFile MakePath(WINDIR$,"win.ini"), MakePath(WINDIR$,"win.cor")
''		CheckBackupFile MakePath(WINDIR$,"reg.dat"), MakePath(WINDIR$,"reg.cor")
''		CheckBackupFile MakePath(WINDIR$,"progman.ini"), MakePath(WINDIR$,"progman.cor")
	ENDIF
	
	IF bInstall(DRAW) AND bInstallNet% = FALSE THEN
		CreateDir MakePath( DIR(MAIN), TR_AUTOBACK ), cmoNone
	ENDIF

	
 	'' If installing as a network administrator, copy redists to redist dir
	''The Redist directory will be created automatically.
	
 	'' Add billboards
	BilBrd% = BILLBOARD1 
	FOR i% = 0 TO 5 STEP 1
		AddToBillBoardList "mscuistf.dll", BilBrd+i%, "FModelessBillBoardDlgProc", 20
	NEXT i%
	
	''Copy all the files over
	WaitOff
	CopyFilesInCopyList
	WaitOn
		
	'' if installing as a network administrator don't create .fot files
	IF bInstallNet% = FALSE THEN
		'' Register all the ttf fonts with Windows
		IF IsTTFEnabled = 1 THEN
				sz$ = UIStartDlg("mscuistf.dll", WAITREGISTER, "FModelessDlgProc", 0, "")
			'' Let's register the Symbols TTF,... FONTLIST1$ is an empty Symbole varaible
			  SetSymbolValue TempList$, "{}"
				IF afState(DRAW) = ALL THEN
					MakeListFromSectionKeys TempList$, "WFN"
				ELSEIF afState(DRAW) = SOME AND GetListItem( OPTS(DRAW), 4) = "ON" THEN
					FOR i% = 1 TO GetListLength(SYMBOLLIST2$)
						AddListItem TempList$, GetListItem(SYMBOLLIST2$, i%)
					NEXT i%
			  ENDIF
				IF bInstall(DRAW) THEN
						AddListItem TempList$, TR_COMMONBULLETS
				ENDIF
				FOR i% = 1 TO GetListLength(TempList$)
					szFileName$ = GetSectionKeyFilename( "WFN", GetListItem(TempList$, i%))
					index% = GetFilenameFromPath( szFileName$ )
					szFileName2$ = MID$( szFileName$, index%, LEN(szFileName$) - index% + 1 )
					IF MID$(szFileName2$, LEN(szFileName2$)-2) = "ttf" THEN
						szFOTName$ = MID$(szFileName2$,1,LEN(szFileName2$)-3) + "fot"
						RegisterFont MakePath(szWWinDir$,szFOTName$), MakePath(DIR(MAIN),TR_SYMBOLS+"\"+szFileName2$)
						temp% = GetTypeFaceNameFromTTF( MakePath(DIR(MAIN),TR_SYMBOLS+"\"+szFileName2$), szString$, STRINGLEN )
						IF temp% > 0 AND temp% < STRINGLEN THEN
							CreateIniKeyValue TR_WIN_INI, "fonts", szString$+" "+TR_TRUETYPE, UCASE$(szFOTName$), cmoOverWrite
						ENDIF
					ENDIF
				NEXT i%
				
				IF afState(FONTTT) = NONE THEN
					SetSymbolValue FONTLIST2$, "{}"
				ENDIF
				IF afState(FONTTT) = ALL THEN
					MakeFontList					
				ENDIF
				IF bInstall(DRAW) THEN
					SetSymbolValue TempList$, "{}"
					MakeListFromSectionKeys TempList$, "DrawFonts"
					FOR i% =1 TO GetListLength(TempList$)
						AddListItem FONTLIST2$, GetListItem(TempList$, i%)
					NEXT i%
				ENDIF
				
				FOR nIndex% = 1 TO GetListLength(FONTLIST2$)
					FOR i% = 1 TO GetListLength(szFontSectDisk$)
						Font$ = GetListItem(FONTLIST2$, nIndex%)
						IF IsSectionKeyExist( GetListItem(szFontSectDisk$, i%), Font$) THEN
							szFileName$ = GetSectionKeyFilename( GetListItem(szFontSectDisk$, i%), Font$)
							EXIT FOR
						ELSEIF IsSectionKeyExist( "DrawFonts", Font$) THEN
							szFileName$ = GetSectionKeyFilename("DrawFonts", Font$ )
							EXIT FOR
						ENDIF
					NEXT i%							
					index% = GetFilenameFromPath( szFileName$ )
					szFileName2$ = MID$( szFileName$, index%, LEN(szFileName$) - index% + 1 )
					szFOTName$ = MID$(szFileName2$,1,LEN(szFileName2$)-3) + "fot"
					RegisterFont MakePath(szWWinDir$,szFOTName$), MakePath(DIR(FONTTT),szFileName2$)
					IF bInstallNet% = FALSE THEN
						temp% = GetTypeFaceNameFromTTF( MakePath(DIR(FONTTT),szFileName2$), szString$, STRINGLEN )
						IF temp% > 0 AND temp% < STRINGLEN THEN
							CreateIniKeyValue TR_WIN_INI, "fonts", szString$+" "+TR_TRUETYPE, UCASE$(szFOTName$), cmoOverWrite
						ENDIF
					ENDIF
					szString$ = string$( STRINGLEN+1, 32 )
					szFileName$ = ""
					szFileName2$ = ""
					szFOTName$ = ""
				NEXT nIndex%
				UIPop 1
		ENDIF
	ENDIF
	
	'' When installing as a network administrator, register nothing
	'' Except for the name and the serialnumber.
	IF bInstallNet% THEN
			RemoveFile MakePath( DIR(MAIN), TR_SETUP+"\"+"setup.exe" ), cmoForce
			RemoveFile MakePath( DIR(MAIN), TR_SETUP+"\"+"setup.lst" ), cmoForce
			RenameFile MakePath( DIR(MAIN), TR_SETUP+"\"+"setup2.exe" ), "setup.exe"
			RenameFile MakePath( DIR(MAIN), TR_SETUP+"\"+"setup2.lst" ), "setup.lst"
			szSerialNumber$ = szSerialNumber$+"-N"
	ENDIF
	IF bInstallNet% = FALSE THEN
	
		sz$ = UIStartDlg("mscuistf.dll", WAITCONFIGER, "FModelessDlgProc", 0, "")
		
 		nAddItemFailed% = 0
		
		'' Updating the INI files in the Config directory	only if an APP installed.
	 	IF bInstallApp% THEN
			'' backup files to *.cor - do not overwrite
			CheckBackupFile MakePath(WINDIR$,"win.ini"), MakePath(WINDIR$,"win.cor")
			CheckBackupFile MakePath(WINDIR$,"reg.dat"), MakePath(WINDIR$,"reg.cor")
			CheckBackupFile MakePath(WINDIR$,"progman.ini"), MakePath(WINDIR$,"progman.cor")
		
			CreateIniKeyValue TR_WIN_INI, "CorelGraphics4", "Dir", MakePath(DIR(MAIN),TR_CONFIG), cmoOverWrite
			RUN( TR_REGLOAD_S + " " + MakePath(WINSYSDIR$, "OLE2.REG") )
			ini$ = MakePath( DIR(MAIN), TR_CONFIG+"\"+TR_CORELAPP_INI)
				CreateIniKeyValue ini$, "Config", "ProgramsDir", MakePath(DIR(MAIN),TR_PROGRAMS), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "DataDir", MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "CustomDir", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "DrawDir", DIR(DRAW), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "ChartDir", DIR(CHART), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "ShowDir", DIR(SHOW), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "PhotoPaintDir", DIR(PHOTO), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "MoveDir", DIR(MOVE), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "TraceDir", DIR(TRACE), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "MosaicDir", DIR(MOSAIC), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "FontsDir", MakePath(DIR(MAIN),TR_SYMBOLS), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "FiltersDir", DIR(FILTERS), cmoOverWrite
				CreateIniKeyValue ini$, "Registration", "UserName", szUserName$, cmoOverWrite
				CreateIniKeyValue ini$, "Registration", "SerialNumber", szSerialNumber$, cmoOverWrite
			ini$ = MakePath( DIR(MAIN), TR_CONFIG+"\"+TR_CORELPRN_INI)
				CreateIniKeyValue ini$, "ColorPath", "CircuitPath", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverwrite
			ini$ = MakePath( DIR(MAIN), TR_CONFIG+"\"+TR_CORELFLT_INI)
				CreateIniKeyValue ini$, "ColorPath", "CircuitPath", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverWrite
				CreateIniKeyValue ini$, "ColorPath", "CurvePath", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverWrite
				WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "ImportFilters", MakePath(DIR(MAIN),TR_PROGRAMS+"\")
				WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "ExportFilters", MakePath(DIR(MAIN),TR_PROGRAMS+"\")
				WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "CorelAIExport", MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA+"\")
				WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "CorelDXFExport", MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_DATA+"\")
			ini$ = MakePath( DIR(MAIN), TR_CONFIG+"\"+TR_CORELFNT_INI)
				WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "Fonts", MakePath(DIR(MAIN),TR_SYMBOLS+"\")
				WrapCommentIniSection ini$, MakePath(Dir(MAIN),"___temp_"), "Symbols", MakePath(DIR(MAIN),TR_SYMBOLS+"\")
				CreateProgmanGroup TOOLGROUP$, "", cmoNone
				ShowProgmanGroup  TOOLGROUP$, 1, cmoNone
				nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_RELEASENOTES, TR_WRITE_EXE + " " + MakePath(DIR(MAIN),TR_README_WRI), "", cmoOverwrite)
				nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, "Manuel de l’utilisateur", MakePath(SrcDir$,"cpnfren.cdr"), "", cmoOverwrite)
				nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, "Carte d’enregistrement", MakePath(SrcDir$,"rcfren.cdr"), "", cmoOverwrite)
		ENDIF
		
		IF bInstall(DRAW) THEN
			'' setup coreldrw.reg
			WrapFileChangeString MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELDRW_REG), MakePath(DIR(MAIN),"___temp_"), TR_CORELDRW_EXE, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELDRW_EXE)
			WrapFileChangeString MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELDRW_REG), MakePath(DIR(MAIN),"___temp_"), TR_CDROL140_DLL, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CDROL140_DLL)
			RUN( TR_REGLOAD_S + " " + MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELDRW_REG) )
			ini$ = MakePath(DIR(MAIN), TR_CONFIG+"\"+TR_CORELDRW_INI)
				CreateIniKeyValue ini$, "Config", "AutoBackupDir", MakePath(DIR(MAIN),TR_AUTOBACK), cmoOverwrite
				CreateIniKeyValue ini$, "Config", "TemplateDir", MakePath(DIR(DRAW),TR_TEMPLATE), cmoOverwrite
			nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_CORELDRAW, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELDRW_EXE),"", cmoOverwrite)
		ENDIF

			IF bInstall(CHART) THEN
				'' setup corelcht.reg
				WrapFileChangeString MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELCHT_REG), MakePath(DIR(MAIN),"___temp_"), TR_CORELCHT_EXE, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELCHT_EXE)
				RUN( TR_REGLOAD_S + " " + MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELCHT_REG) )
				ini$ = MakePath(DIR(MAIN), TR_CONFIG+"\"+"CORELCHT.INI")
				'$IFNDEF INSTALLCD
					CreateIniKeyValue ini$, "Config", "Vector_path", MakePath(DIR(MAIN),TR_CLIPART+"\"+TR_VECTORS), cmoOverwrite
				'$ELSE
					CreateIniKeyValue ini$, "Config", "Vector_path", MakePath(SrcDir$,TR_CLIPART+"\"+TR_VECTORS), cmoOverwrite
				'$ENDIF
					CreateIniKeyValue ini$, "Templates", "1", CHR$(34)+TR_BAR+CHR$(34)+","+MakePath(DIR(CHART),TR_BAR), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "2", CHR$(34)+TR_LINE+CHR$(34)+","+MakePath(DIR(CHART),TR_LINE), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "3", CHR$(34)+TR_AREA+CHR$(34)+","+MakePath(DIR(CHART),TR_AREA), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "4", CHR$(34)+TR_PIE+CHR$(34)+","+MakePath(DIR(CHART),TR_PIE), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "5", CHR$(34)+TR_SCATTER+CHR$(34)+","+MakePath(DIR(CHART),TR_SCATTER), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "6", CHR$(34)+TR_HIGH+"/"+TR_LOW+"/"+TR_OPEN+"/"+TR_CLOSE+CHR$(34)+","+MakePath(DIR(CHART),TR_HILO), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "7", CHR$(34)+TR_SPECTRAL_MAPS+CHR$(34)+","+MakePath(DIR(CHART),TR_SPECTRAL), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "8", CHR$(34)+TR_HISTOGRAMS+CHR$(34)+","+MakePath(DIR(CHART),TR_HIST), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "9", CHR$(34)+TR_TABLE_CHARTS+CHR$(34)+","+MakePath(DIR(CHART),TR_TABLE), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "10", CHR$(34)+TR_3D_RISER+CHR$(34)+","+MakePath(DIR(CHART),TR_3DRISER), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "11", CHR$(34)+TR_3D_SCATTER+CHR$(34)+","+MakePath(DIR(CHART),TR_3DSCAT), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "12", CHR$(34)+TR_PICTOGRAPHS+CHR$(34)+","+MakePath(DIR(CHART),TR_PICTO), cmoOverwrite
					CreateIniKeyValue ini$, "Templates", "13", CHR$(34)+TR_SAMPLES+CHR$(34)+","+MakePath(DIR(CHART),TR_SAMPLES), cmoOverwrite
				nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_CORELCHART, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELCHT_EXE), "", cmoOverwrite)
			ENDIF

			IF bInstall(SHOW) THEN
				'' setup corelshw.reg
				WrapFileChangeString MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELSHW_REG), MakePath(DIR(MAIN),"___temp_"),TR_CORELSHW_EXE, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELSHW_EXE)
				RUN( TR_REGLOAD_S + " " + MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELSHW_REG) )
				CreateIniKeyValue TR_WIN_INI, "AAPLAY Animation", "WaveAudio", "c,522", cmoOverWrite
				CreateIniKeyValue TR_WIN_INI, "AAPLAY Animation", "Sequencer", "x,523", cmoOverWrite
				CreateIniKeyValue TR_WIN_INI, "AAPLAY Animation", "FullScreen", "AAVGA.DLL", cmoOverWrite
				CreateIniKeyValue TR_WIN_INI, "AAPLAY Animation", "DualScreen", "no", cmoOverWrite
				ini$ = MakePath(DIR(MAIN), TR_CONFIG+"\"+TR_CORELSHW_INI)
					CreateIniKeyValue ini$, "HomeDirectories", "Presentations", MakePath(DIR(SHOW), TR_SAMPLES), cmoOverwrite
					CreateIniKeyValue ini$, "HomeDirectories", "Animations", MakePath(DIR(SHOW),TR_SAMPLES), cmoOverwrite
				nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_CORELSHOW, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELSHW_EXE), "", cmoOverwrite)
			ENDIF


			IF bInstall(PHOTO) THEN
				'' Register photo with OLE
				WrapFileChangeString MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELPNT_REG), MakePath(DIR(MAIN),"___temp_"),TR_CORELPNT_EXE, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELPNT_EXE)
				WrapFileChangeString MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELPNT_REG), MakePath(DIR(MAIN),"___temp_"),TR_PNTHNDLR_DLL, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_PNTHNDLR_DLL)
				RUN( TR_REGLOAD_S + " " + MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELPNT_REG) )
				ini$ = MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELPNT_INI)
					CreateIniKeyValue ini$, "CorelPaintDll", "PCX 16 Color/Gray", MakePath(DIR(MAIN),TR_PROGRAMS+"\"+"pcx16.dll,*.pcx"), cmoOverWrite
					CreateIniKeyValue ini$, "ARTIST", "Path", MakePath(DIR(PHOTO),TR_BRUSHES+"\"), cmoOverWrite
					CreateIniKeyValue ini$, "COLORSELECT", "Brush", MakePath(DIR(PHOTO),TR_BRUSHES+"\"+TR_PNTBRUSH_BMP), cmoOverWrite
					CreateIniKeyValue ini$, "COLORSELECT", "Area", MakePath(DIR(PHOTO),TR_COLORS+"\"+TR_DEFAULT_CLR), cmoOverWrite
'' Make the following as variable in setupvar.raw ......
					CreateIniKeyValue ini$, "CANVAS", "Canvas", MakePath(DIR(PHOTO),TR_CANVAS+"\"+TR_CANVAS_PCX), cmoOverWrite
					CreateIniKeyValue ini$, "ColorPath", "CircuitPath", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverWrite
					CreateIniKeyValue ini$, "ColorPath", "CurvePath", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverWrite
					CreateIniKeyValue ini$, "ColorPath", "TargetPath", MakePath(DIR(MAIN),TR_CUSTOM), cmoOverWrite
					CreateIniKeyValue ini$, "FILL", "Fill", MakePath(DIR(PHOTO),TR_TILES+"\"+TR_TILES_PCX), cmoOverWrite
				nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_CORELPHOTO, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELPNT_EXE), "", cmoOverwrite)
				nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_CCAPTURE, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CCAPTURE_EXE), "", cmoOverwrite)
			ENDIF
		
			IF bInstall(MOVE) THEN
				'' Register move with OLE
				WrapFileChangeString MakePath(DIR(MAIN),TR_CONFIG+"\"+"corelmov.reg"), MakePath(DIR(MAIN),"___temp_"),TR_CORELMOV_EXE, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELMOV_EXE)
				RUN( TR_REGLOAD_S + " " + MakePath(DIR(MAIN),TR_CONFIG+"\"+"corelmov.reg") )
				ini$ = MakePath(DIR(MAIN),TR_CONFIG+"\"+TR_CORELMOV_INI)
					CreateIniKeyValue ini$, "Config", "FilterDir", MakePath(DIR(MAIN),TR_PROGRAMS), cmoOverWrite
				'' Make the changes for media player installation	
				ini$ = MakePath(WINDIR$, "system.ini")
					CopyFile MakePath(WINDIR$, "system.ini"), MakePath(WINDIR$, "system.cor"), cmoOverwrite, 0
					CreateIniKeyValue ini$, "mci", "CorelMOVE", MakePath(DIR(MAIN),TR_PROGRAMS+"\"+"mcicmv40.drv"), cmoOverWrite
					CreateIniKeyValue ini$, "drivers", "VIDC.MSVC", "msvidc.drv", cmoOverWrite
					CreateIniKeyValue TR_WIN_INI, "mci extensions", "cmv", "CorelMOVE", cmoOverWrite
					CreateIniKeyValue TR_WIN_INI, "mci extensions", "mwf", "CorelMOVE", cmoOverWrite
				ini$ = MakePath(WINDIR$, "MPLAYER.INI")
					CopyFile MakePath(WINDIR$, "mplayer.ini"), MakePath(WINDIR$, "mplayer.cor"), cmoOverwrite, 0
					CreateIniKeyValue ini$, "Devices", "CorelMOVE", "350, CorelMove Player", cmoOverWrite
				nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_CORELMOVE, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELMOV_EXE), "", cmoOverwrite)
			ENDIF

		IF bInstall(TRACE) THEN
			ini$ = MakePath(DIR(MAIN),TR_CONFIG+"\"+"coreltrc.ini")
				CreateIniKeyValue ini$, "Config", "1", MakePath(DIR(TRACE),"NORMAL.CTR"), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "2", MakePath(DIR(TRACE),"DITHERED.CTR"), cmoOverWrite
				CreateIniKeyValue ini$, "Config", "3", MakePath(DIR(TRACE),"BIGFORMS.CTR"), cmoOverWrite
			nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_CORELTRACE, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELTRC_EXE), "", cmoOverwrite)
		ENDIF
		
		IF bInstall(MOSAIC) THEN
			nAddItemFailed% = nAddItemFailed% + CreateProgmanItem( TOOLGROUP$, TR_CORELMOSAIC, MakePath(DIR(MAIN),TR_PROGRAMS+"\"+TR_CORELMOS_EXE), "", cmoOverwrite)
		ENDIF
		
		UIPop 1 ''WAITCONFIGER Dialog
		
		IF nAddItemFailed% > 0 THEN
			Dialog% = NETADDITEMFAILED
			GOSUB INFO
		ENDIF
		
		'' Is the system set up to allow us to print the samples?
		'' Print option is canceled, no printing any more!!!!! 16Apr93
		
		''Let's get the bootable drive, by looking at COMSPEC enviro variable
		Drive$ = CHR$( FGetBootDrive - 1 + ASC("A"))
''		WriteToLOgFile "Bootable Drive is : " + Drive$
		'' If Scanners installed we need to add the lines to config.sys & autoexec.bat
		IF afState(SCANNERS) = SOME THEN
			ini$ = MakePath(WINDIR$,TR_TWAIN+"\"+TR_COREL+"\CORTWAIN.INI")
			IF bDosScanner% THEN
				IF GetListLength(AUTOEXECLINE$) THEN
					CopyFile Drive$+":\"+TR_AUTOEXEC_BAT, Drive$+":\"+TR_AUTOEXEC_COR, cmoOverwrite, 0
					bAutoexecModified% = TRUE
					Dialog% = UPDATEAUTOEXEC
					'' We'll use same variables used for the other parts, it could be insignificant
					szFlist1a = TR_AUTOEXEC_BAT
					szFlist1b = TR_AUTOEXEC_COR
					szOptions$ = AUTOEXECLINE$
					szTempVar$ = "E"
					GOSUB UPDATE
				ENDIF
				IF GetListLength(CONFIGLINE$) THEN
					CopyFile Drive$+":\"+TR_CONFIG_SYS, Drive$+":\"+TR_CONFIG_COR, cmoOverwrite, 0
					Dialog% = UPDATECONFIG
					'' We'll use same variables used for the other parts, it could be insignificant
					szFlist1a = TR_CONFIG_SYS
					szFlist1b = TR_CONFIG_COR
					szOptions$ = CONFIGLINE$
					szTempVar$ = "B"
					GOSUB UPDATE
				ENDIF
				CreateIniKeyValue ini$, "ZSTWAIN.DLL", "path", MakePath(DIR(SCANNERS), "zstwain.dll"), cmoOverWrite
			ELSEIF bTwainScanner% THEN
				CreateIniKeyValue ini$, "CANON", "IPUBJS-SCANNER", MakePath(DIR(SCANNERS),"canoncj1.dll"), cmoOverWrite
			ENDIF
		ENDIF
'' Installing SHARE
		'' We don't want to install SHARE for Windows for Workgroups
		IF bWindowsForWorkgroups% = FALSE THEN
			ShareFile$ = FindFileInTree("SHARE.EXE", Drive$+":\")
			IF ShareFile <> "" THEN
				SetSymbolValue "ShareLine", "{}"
				AddListItem "ShareLine", ShareFile$+" /L:500 /F:5100"
				IF bAutoexecModified% = FALSE THEN
					CopyFile Drive$+":\"+TR_AUTOEXEC_BAT, Drive$+":\"+TR_AUTOEXEC_COR, cmoOverwrite, 0
				ENDIF
				Dialog% = UPDATEAUTOEXECFORSHARE
				szFlist1a = TR_AUTOEXEC_BAT
				szFlist1b = TR_AUTOEXEC_COR
				szOptions$ = "ShareLine"
				szTempVar$ = "E"
				GOSUB UPDATE
			ENDIF
		ENDIF
		
		
	ELSE			'' if a network administrator
		ini$ = MakePath( DIR(MAIN), TR_SETUP+"\"+TR_SETUP_INI )
		CreateIniKeyValue ini$, "Directories", TR_FIXEDDRIVE, "FALSE", cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_DRAW, DIR(DRAW), cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_CHART, DIR(CHART), cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_SHOW, DIR(SHOW), cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_PHOTOPNT, DIR(PHOTO), cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_MOVE, DIR(MOVE), cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_TRACE, DIR(TRACE), cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_MOSAIC, DIR(MOSAIC), cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_WFN, MakePath(DIR(MAIN),TR_SYMBOLS), cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_TTF, DIR(FONTTT), cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_SCANNERS, DIR(SCANNERS), cmoOverwrite
		CreateIniKeyValue ini$, "Directories", TR_MAIN, DIR(MAIN), cmoOverwrite
		CreateIniKeyValue ini$, "Registration", "UserName", szUserName$, cmoOverWrite
		CreateIniKeyValue ini$, "Registration", "SerialNumber", szSerialNumber$, cmoOverWrite
	ENDIF			'' end 'network administrator?'
	
			
 	'' Do print test?
	'' Print test samples is obselete. 16Apr93


'' User has completed run of setup or has unconditionally decided to quit
QUIT:
	WaitOff
	'' On MSTest errors report "setup file corrupted" and abort
	ON ERROR GOTO ERRQUIT

	IF ERR = 0 THEN
		sz$ = UIStartDlg("mscuistf.dll", SUCCESS, "FSuccessBitmapDlgProc", 0, "")
		dlg% = EXITSUCCESS
		szDlgProc$ = "FInfo075DlgProc"
		WriteToLogfile TR_SETUPSUCCEEDED
	ELSEIF ERR = STFQUIT THEN
		dlg% = EXITQUIT
		szDlgProc$ = "FInfo0DlgProc"
		WriteToLogfile TR_SETUPQUIT
	ELSE
		dlg% = ERROREXITFAILURE
		szDlgProc$ = "FInfo0DlgProc"
		WriteToLogfile TR_SETUPFAILED
	ENDIF
''	WriteToLogfile ""
	
 
'' Put up one of the exit message dialog boxes
QUITL1:
	sz$ = UIStartDlg("mscuistf.dll", dlg%, szDlgProc, 0, "")
	IF sz$ = "REACTIVATE" THEN
		GOTO QUITL1
	ENDIF
 GOTO FINISH


'' An error has occurred in MSTest. Tell the user and abort.
ERRQUIT:
	i% = DoMsgBox( TR_ERRQUIT, TR_SETUPMESSAGE, MB_OK+MB_TASKMODAL+MB_ICONHAND)
	WriteToLogfile TR_SETUPCORRUPTED
	WriteToLogFile ""
FINISH:
	UIPopAll
	ShutDownInstall
	CloseLogFile
	END


'' allow the user to select all the customize options
CUSTINST:
	bBack% = FALSE
	RemoveSymbol "InstallDirs"
	RemoveSymbol "InstallState"
	'' pass current directories and custom install state to dlgproc
	FOR i%= 1 to NUMCUST STEP 1
		AddListItem "InstallDirs", DIR(i%)
		AddListItem "InstallState", NUM(afState(i%))
	NEXT i%

	''Do a full recalculation if necessary
	IF bRecalc% THEN
		WaitOnBig
		bRecalc% = FALSE
		RecalcPath
	ENDIF
	IF bFullInstall% THEN 
		GOTO CUSTINSTL2
	ENDIF
	
CUSTINSTL1:	
	WaitOn
	''Do a full recalculation if necessary
	SetDriveStatus				'' set DriveText$ and StatusText$
	WaitOff
	sz$ = UIStartDlg("mscuistf.dll", CUSTINST1, "FCustInstDlgProc", CUSTINSTHELP, "FHelpDlgProc")
	FOR i% = SCANNERS TO FONTTT
		ReplaceListItem "InstallDirs", i%, DIR(i%)
		ReplaceListItem "InstallState", i%, NUM(afState(i%))
	NEXT i%
	
	SELECT CASE sz$
	CASE "CONTINUE"
		WaitOn
		GOSUB SetDirFromSymbol	'' set afState and DIR array from symbols
		IF bBadPath% THEN
			GOTO CUSTINSTL1
		ENDIF
		SetDriveStatus					'' Test for not enough space
		IF bTooBig% THEN
			Dialog% = TOOBIG
			GOSUB INFO
			GOTO CUSTINSTL1
		ENDIF
		
	 	IF bInstall(CHART) AND bInstall(DRAW) = FALSE THEN
			afState(DRAW) = SOME
			ReplaceListItem OPTS(DRAW), 1, "ON"	
		  FOR i% = 2 TO 4
				ReplaceListItem OPTS(DRAW), i%, "OFF"
			NEXT i%
    '$IFNDEF INSTALLCD
			ReplaceListItem OPTS(DRAW), 5, "OFF"
		'$ENDIF
			ReplaceListItem "InstallState", DRAW, NUM(afState(DRAW))
			Dialog% = INSTALLINGDRAW
			GOSUB INFO	
			RecalcOptFiles DRAW
		ENDIF
		WriteToLogFile TR_MAIN + " - " + DIR(MAIN)
		WriteToLogFile TR_DIRECTORIES
		WriteToLogFile TR_CUSTOMSELECT
		WriteToLogFile TR_CUSTOMMESSAGE
		WriteToLogFile TR_CORELDRAW  + " - " + DIR(DRAW)+ " - " + STR$(afState(DRAW)) + " - " + GetSymbolValue(OPTS(DRAW))
		WriteToLogFile TR_CORELCHART + " - " + DIR(CHART)+ " - " + STR$(afState(CHART)) + " - " + GetSymbolValue(OPTS(CHART))
		WriteToLogFile TR_CORELSHOW  + " - " + DIR(SHOW)+ " - " + STR$(afState(SHOW)) + " - " + GetSymbolValue(OPTS(SHOW))
		WriteToLogFile TR_CORELPHOTO + " - " + DIR(PHOTO)+ " - " + STR$(afState(PHOTO)) + " - " + GetSymbolValue(OPTS(PHOTO))
		WriteToLogFile TR_CORELMOVE  + " - " + DIR(MOVE)+ " - " + STR$(afState(MOVE)) + " - " + GetSymbolValue(OPTS(MOVE))
		WriteToLogFile TR_CORELTRACE + " - " + DIR(TRACE)+ " - " + STR$(afState(TRACE)) 
		WriteToLogFile TR_CORELMOSAIC+ " - " + DIR(MOSAIC)+ " - " + STR$(afState(MOSAIC))
		WriteToLogFile TR_ASTERIXES
		
	CASE "CUST1"
		WaitOn
		szOptions$ = OPTS(DRAW)
		'$IFDEF INSTALLCD
			Dialog% = CDROMCUSTDRAW
		'$ELSE
			Dialog% = FLOPPYCUSTDRAW
		'$ENDIF
		SelectType% = DRAW
		GOTO SAVE3LINES
	CASE "CUST2"
		WaitOn
		szOptions$ = OPTS(CHART)
		Dialog% = CUSTCHART
		SelectType% = CHART
		GOTO SAVE3LINES
	CASE "CUST3"
		WaitOn
		szOptions$ = OPTS(SHOW)
		Dialog% = CUSTSHOW
		SelectType% = SHOW
		GOTO SAVE3LINES
	CASE "CUST4"
		WaitOn
		szOptions$ = OPTS(PHOTO)
		Dialog% = CUSTPHOTO
		SelectType% = PHOTO
		GOTO SAVE3LINES
	CASE "CUST5"
		WaitOn
		szOptions$ = OPTS(MOVE)
		Dialog% = CUSTMOVE
		SelectType% = MOVE
		GOTO SAVE3LINES

	''reset afState, the drive status and status text
	CASE "RESET"
		WaitOn
		GOSUB SetDirFromSymbol	'' set afState and DIR array from symbols
		GOTO CUSTINSTL1
		
	CASE "REACTIVATE"
		GOSUB SetDirFromSymbol	'' set afState and DIR array from symbols
		GOTO CUSTINSTL1
		
	CASE "CANCEL", "BACK"
		WaitOn
		UIPop 1
		bBack% = TRUE
		RETURN
		
	CASE ELSE
		GOSUB ASKQUIT
		GOSUB SetDirFromSymbol	'' set afState and DIR array from symbols
		GOTO CUSTINSTL1
	END SELECT
	UIPop 1
	
CUSTINSTL2:	
	WaitOn
	SetSymbolValue EXPFILTERLIST1$, "{}"
	SetSymbolValue IMPFILTERLIST1$, "{}"
	MakeListFromSectionKeys EXPFILTERLIST2$, "ExpFilters"
	MakeListFromSectionKeys IMPFILTERLIST2$, "ImpFilters"
	AddRemainingFilters
	RecalcOptFiles FILTERS
	MakeFontList
		WaitOnBig
''	SetDriveStatus
	
CUSTINSTL22:
		
	''Do a full recalculation if necessary
''	GOSUB SetDirFromSymbol	
	SetDriveStatus				'' set DriveText$ and StatusText$
	WaitOff
	
	sz$ = UIStartDlg("mscuistf.dll", CUSTINST2, "FCustInstDlgProc", CUSTINSTHELP, "FHelpDlgProc")
	
	FOR i% = DRAW TO MOSAIC
		ReplaceListItem "InstallDirs", i%, DIR(i%)
		ReplaceListItem "InstallState", i%, NUM(afState(i%))
	NEXT i%
	
	SELECT CASE sz$
	CASE "CONTINUE"
		WaitOn
		GOSUB SetDirFromSymbol	'' set afState and DIR array from symbols
		IF bBadPath% THEN
			GOTO CUSTINSTL22
		ENDIF
		SetDriveStatus					'' Test for not enough space
		IF bTooBig% THEN
			Dialog% = TOOBIG
			GOSUB INFO
			GOTO CUSTINSTL22
		ENDIF
		'$IFDEF INSTALLCD
			IF afState(FONTTT) = ALL THEN
				'Dialog% = MOREFONTS
				'GOSUB INFO
			ENDIF
		'$ENDIF
		
		WriteToLogFile TR_DIRECTORIES
		WriteToLogFile TR_FILTERS + " - " + STR$(afState(FILTERS)) + " - " + DIR(FILETRS)
		WriteToLogFile TR_TTF + " - " + STR$(afState(FONTTT)) + " - " + DIR(FONTTT)
		WriteToLogFile TR_SCANNERS + " - " + STR$(afState(SCANNERS)) + " - " + DIR(SCANNERS)
		WriteToLogFile TR_ASTERIXES
		
	CASE "CUST8"
		WaitOn
		FOR i%=1 TO 3
			AddListItem "StatusText", ""
		NEXT i%
		InitScannerSelection
		bDosScanner% = FALSE
		bTwainScanner% = FALSE
		GOSUB CUSTSCANNERS
		CloseScannerSelection
		GOTO CUSTINSTL22
	CASE "CUST9"
		WaitOn
			szFList1a$ = EXPFILTERLIST1$
			szFList1b$ = EXPFILTERLIST2$
			szFList2a$ = IMPFILTERLIST1$
			szFList2b$ = IMPFILTERLIST2$
		Dialog% = SELECTFILTERS
		SelectType% = FILTERS
		GOSUB SELECTFILES
		GOTO CUSTINSTL22
	CASE "CUST10"
		WaitOn
		SelectType% = FONTTT
		'$IFDEF INSTALLCD
			Dialog% = SELECTFONTTTCD
		'$ELSE
			Dialog% = SELECTFONTTT
		'$ENDIF
			szFList1a$ = FONTLIST1$
			szFList1b$ = FONTLIST2$
			GOSUB SELECTFILES
			GOTO CUSTINSTL22
		
	''reset afState, the drive status and status text
	CASE "RESET"
		WaitOn
		GOSUB SetDirFromSymbol	'' set afState and DIR array from symbols
		GOTO CUSTINSTL22
		
	CASE "REACTIVATE"
		GOSUB SetDirFromSymbol	'' set afState and DIR array from symbols
		GOTO CUSTINSTL22
		
	CASE "CANCEL", "BACK"
		WaitOn
		UIPop 1
		IF bFullInstall% THEN
			bBack% = TRUE
			RETURN
		ELSE
			GOTO CUSTINSTL1
		ENDIF
		
	CASE ELSE
		GOSUB ASKQUIT
		GOSUB SetDirFromSymbol	'' set afState and DIR array from symbols
		GOTO CUSTINSTL22
	END SELECT
	UIPop 1
''	IF bFullInstall% THEN
''		RETURN    '' The work needed is done, let's install the files.
''	ENDIF
	
'' Don't ask what progman group to use if installing as an administrator
'' Since the group selection is deleted, we don't need to jump anything: 16Apr93

'' Fall through from CUSTINST
''set the default progman group to put everything in
TOOLGROUP$	= TR_TOOLGROUP

'' Let the user select the progman group where all executables will be stored
'' the selection of different groups and exev group name was deleted: 16Apr93
	
''Fall through from SelectGroups - or from SelectCustGroups
'' Ask the user if he wants to change any of his selections. If so, let him
''   work his way back by hitting the "back" button
ASKINSTALL:
	WaitOff
	sz$ = UIStartDlg( "mscuistf.dll", ASKINSTALL, "FInfoDlgProc", ASKINSTALLHELP, "FHelpDlgProc" )
	SELECT CASE sz$
	CASE "CONTINUE"
		''Do nothing
	CASE "CANCEL", "BACK"
		UIPop 1
			GOTO CUSTINSTL22
	CASE "REACTIVATE"
		GOTO ASKINSTALL
	CASE ELSE
		GOSUB ASKQUIT
		GOTO ASKINSTALL
	END SELECT
	UIPop 1
RETURN		''return to OPTIONS - going to INSTALL
	
 

'' Let the user customize the progman groups where each executable will be
'' stored
'' the choice was deleted: 16Apr93

'' this will save 3 lines per each option in CUSTINSTL1 ;-)
SAVE3LINES:
		GOSUB SetDirFromSymbol	'' set afState and DIR array from symbols
		IF bBadPath% THEN
			GOTO CUSTINSTL1
		ENDIF
		GOSUB CUSTINST2
		GOTO CUSTINSTL1


'' Input the custom installation choices for DRAW .. MOVE
CUSTINST2:
	SetSymbolValue "CheckItemsIn", GetSymbolValue( szOptions$ )
		szOldSymbolList1$ = GetSymbolValue(SYMBOLLIST1$)
		szOldSymbolList2$ = GetSymbolValue(SYMBOLLIST2$)
CUSTINST2L1:
	WaitOff
	sz$ = UIStartDlg("mscuistf.dll", Dialog%, "FCheckDlgProc", CUSTINST2HELP, "FHelpDlgProc")

	SELECT CASE sz$
	CASE "CONTINUE"
		WaitOn
		newopt$ = GetSymbolValue("CheckItemsOut")
''		IF bCustomBottom% THEN
''			'' if we might have customized the Symbols, or the fonts
''			'' we need to recalculate the new list
''			SetSymbolValue szOptions$, newopt$
''			RecalcOptFiles SelectType%
''			bCustomBottom% = FALSE
''		ELSEIF newopt$ <> GetSymbolValue(szOptions$) THEN
		IF newopt$ <> GetSymbolValue(szOptions$) THEN
			'' otherwise, only recalc if we changed things 
			SetSymbolValue szOptions$, newopt$
			RecalcOptFiles SelectType%
		ENDIF
		
	CASE "BTN1"
		''This will only happen if customizing Symbols selection in Draw
		''Or (4.0) customize font selection, which is for TTFonts in CDROM Install
		bCustomBottom% = TRUE
				szFList1a$ = SYMBOLLIST1$
				szFList1b$ = SYMBOLLIST2$
			oldDialog% = Dialog%
			Dialog% = SELECTFONTSYM
			GOSUB SELECTFILES
			Dialog% = oldDialog%
			GOTO CUSTINST2L1
		
	CASE "REACTIVATE"
		GOTO CUSTINST2L1
		
	CASE "CANCEL", "BACK"
			'' reset Symbols
			SetSymbolValue SYMBOLLIST1$, szOldSymbolList1$
			SetSymbolValue SYMBOLLIST2$, szOldSymbolList2$
			
	CASE ELSE
		GOSUB ASKQUIT
		GOTO CUSTINST2L1
		
	END SELECT
	UIPop 1
RETURN

CUSTSCANNERS:
	 	AddListItem "CombosStatus", GetListItem("ScanList", 1)
		IF GetListLength("OptionList") THEN
		 	AddListItem "CombosStatus", GetListItem("OptionList", 1)
		ELSE
		 	AddListItem "CombosStatus", ""
		ENDIF
		IF GetListLength("SubOptionList") THEN
		 	AddListItem "CombosStatus", GetListItem("SubOptionList", 1)
		ELSE
		 	AddListItem "CombosStatus", ""
		ENDIF
		bDosScanner% = 0
		bTwainScanner% = 0
			
CUSTSCANNERS2:
	WaitOff
	
	sz$ = UIStartDlg("mscuistf.dll", CUSTSCAN, "FScannerDlgProc", CUSTSCANHELP, "FHelpDlgProc")

	SELECT CASE sz$
	CASE "CONTINUE"
		SetSymbolValue SCANNERSECTION, "{}"
		SetSymbolValue CONFIGLINE, "{}"
		SetSymbolValue AUTOEXECLINE, "{}"
		bDosScanner% = FGetScannerLine(DIR(SCANNERS)+"\")
		bTwainScanner% = NOT bDosScanner%
		IF afState(SCANNERS) <> SOME THEN
			afState(SCANNERS) = SOME  
		ENDIF
		WaitOn
		GOSUB SetDirFromSymbol	
		RecalcOptFiles SCANNERS
	
	CASE "COMBO1"
		GOTO CUSTSCANNERS2
	CASE "COMBO2"
		GOTO CUSTSCANNERS2
	CASE "COMBO3"
		GOTO CUSTSCANNERS2
		
	CASE "REACTIVATE"
		GOTO CUSTSCANNERS2
		
	CASE "CANCEL"
		UIPop 1
		RETURN
			
	CASE ELSE
		GOSUB ASKQUIT
		GOTO CUSTSCANNERS2
		
	END SELECT
	UIPop 1
RETURN

'' Display an information dialog
'' Uses the global Dialog% to identify which dialog to display
INFO:
	WaitOff
	sz$ = UIStartDlg( "mscuistf.dll", Dialog%, "FInfo0DlgProc", 0, "" )
	SELECT CASE sz$
	CASE "CONTINUE"
		''Do nothing
	CASE "REACTIVATE"
		GOTO INFO
	CASE "EXIT"
		GOSUB ASKQUIT
		GOTO INFO
	END SELECT
	UIPop 1
RETURN

'' Get the base directory under which CorelDRAW! will be installed
GETPATH:
	bBack% = FALSE
	bRet% = FIsDrawExist(TR_WIN_INI, szString$)
	IF bRet% THEN  '' We have DRAW installed before (could be DRAW3 or DRAW4)
		DEST$ = szString$
		DIR(MAIN) = DEST$
		SetDirectories
	ENDIF
		Dialog% = DESTPATH
	SetSymbolValue "EditTextIn", DEST$
	SetSymbolValue "EditFocus", "END"
GETPATHL1:
	WaitOff
	sz$ = UIStartDlg("mscuistf.dll", Dialog%, "FEditDlgProc", DESTPATHHELP, "FHelpDlgProc")
	SELECT CASE sz$
	CASE "CONTINUE"
		WaitOn
		olddest$ = DEST$
		DEST$ = RTRIM$(LTRIM$(GetSymbolValue("EditTextOut")))
		''Validate new path.
		IF DEST$ = "" OR IsDirWritable(DEST$) = 0 THEN
			OldDialog% = Dialog%
			Dialog% = ERRORBADPATH
			GOSUB INFO
			Dialog% = OldDialog%
			GOTO GETPATHL1
		ENDIF

		''Set Recalc and change subdirectories if DEST$ changed
		IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
			DIR(MAIN) = DEST$
			SetDirectories
		ENDIF
		
	CASE "REACTIVATE"
		GOTO GETPATHL1
	CASE "CANCEL", "BACK"
		UIPop 1
		bBack% = TRUE
		RETURN
	CASE ELSE
		GOSUB ASKQUIT
		GOTO GETPATHL1
	END SELECT
	WriteToLogFile TR_BASEDIR + DEST$
	WriteToLogFile ""
	UIPop 1
RETURN


'' The user has asked to quit - confirm his decision
ASKQUIT:
	WaitOff
	sz$ = UIStartDlg("mscuistf.dll", ASKQUIT, "FQuitDlgProc", 0, "")
	SELECT CASE sz$
	CASE "EXIT"
		GOTO FINISH		'' OK. I know I shouldn't do that, but it's OK, It's the end of script.
''		UIPopAll
''		ERROR STFQUIT
	CASE "REACTIVATE"
		GOTO ASKQUIT
	CASE ELSE
		''Do nothing
	END SELECT
	UIPop 1
RETURN


'' Permit the user to select which filters or fonts/symbols he wants to install
SELECTFILES:
	GOSUB SetDirFromSymbol	
	SetSymbolValue "ListItems1a", GetSymbolValue( szFList1a$ )
	SetSymbolValue "ListItems1b", GetSymbolValue( szFList1b$ )
	IF Dialog% = SELECTFILTERS THEN
		SetSymbolValue "ListItems2a", GetSymbolValue( szFList2a$ )
		SetSymbolValue "ListItems2b", GetSymbolValue( szFList2b$ )
	ENDIF

SELECTL1:
	WaitOff
	sz$ = UIStartDlg("mscuistf.dll", Dialog%, "FList4DlgProc", SELECTHELP, "FHelpDlgProc")
	
	SELECT CASE sz$
	CASE "CONTINUE"
		WaitOn
		''If lists have been modified, reset them and recalculate
		SetSymbolValue szFList1a$, GetSymbolValue("ListItems1a")
		SetSymbolValue szFList1b$, GetSymbolValue("ListItems1b")
		IF Dialog% = SELECTFILTERS THEN
			SetSymbolValue szFList2a$, GetSymbolValue("ListItems2a")
			SetSymbolValue szFList2b$, GetSymbolValue("ListItems2b")
		ENDIF
		UIPop 1
			RecalcOptFiles SelectType%
	CASE "REACTIVATE"
		GOTO SELECTL1
	CASE "CANCEL", "BACK"
		UIPop 1
		IF SelectType% = FONTSYM OR SelectType% = FONTTT THEN
			WaitOnBig
			RecalcOptFiles SelectType%
		ENDIF
	CASE ELSE
		GOSUB ASKQUIT
		GOTO SELECTL1
	END SELECT
	RemoveSymbol "ListItems1a"
	RemoveSymbol "ListItems1b"
	RemoveSymbol "ListItems2a"
	RemoveSymbol "ListItems2b"
RETURN

UPDATE:
			WaitOff
			Drive$ = MID$ (GetEnvVariableValue("COMSPEC"), 1, 1)
	 		sz$ = UIStartDlg( "mscuistf.dll", Dialog%, "FButtonsDlgProc", UPDATEHELP, "FHelpDlgProc" )
  	  SELECT CASE sz$
    		CASE "U"
					Res% = FModifyFile(Drive$+":\"+szFlist1a$, szOptions$, szTempVar$)
				CASE "D"
					Res% = FModifyFile(Drive$+":\"+szFlist1b$, szOptions$, szTempVar$)
				CASE ELSE
					GOTO UPDATE
			END SELECT
					UIPop 1
			RETURN
		

'$INCLUDE 'draw2.mst'
