'************************************************************************
'*                       PackRat 5.0
'************************************************************************
'* Copyright (c) 1991, 1992 - Polaris Software - All Rights Reserved
'***********************************************************************/

'$DEFINE DEBUG

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

''Dialog ID's
CONST WELCOME       = 100
CONST NEWINSTALL    = 101
CONST ASKQUIT       = 200
CONST DESTPATH      = 300
CONST GETWORDMACRODIR   = 305
CONST GETEXCELMACRODIR   = 304
CONST GETAMIMACRODIR   = 302
CONST GETWPMACRODIR   = 303
''CONST GETMACRODIR   = 301
CONST EXITFAILURE   = 400
CONST EXITQUIT      = 600
CONST EXITSUCCESS   = 700
CONST OPTIONS       = 800
CONST APPHELP       = 900
CONST CHECK         = 2500
CONST MSELECTPIL    = 5200
CONST MSELECTDB     = 5201
CONST MSELECTPDA    = 5202
CONST CUSTINST      = 6200
CONST TOOBIG        = 6300
CONST BADPATH       = 6400
CONST GETNAME       = 7500
CONST INFOENTERED   = 7300
CONST NAMEREQ       = 7700
CONST SUGGEST       = 8111

''Bitmap ID
CONST LOGO         = 1

''File Types
CONST PROGRAMFILES     = 1
CONST HELPFILES        = 2
CONST MXLFILES         = 3
CONST PDAFILES         = 4
CONST SPELLER          = 5
CONST PILFILES         = 6
CONST DBFILES          = 7

CONST NumOfItems       = 7

GLOBAL CUIDLL$
GLOBAL HELPPROC$

GLOBAL USERNAME$
GLOBAL COMPANY$
GLOBAL WORDMACRO$
GLOBAL WPMACRO$
GLOBAL AMIMACRO$
GLOBAL EXCELMACRO$

GLOBAL AppName$
GLOBAL DEST$
GLOBAL WINDRIVE$
GLOBAL WINDIR$
GLOBAL WINSYSDIR$
GLOBAL UPDATENEW%

CONST  NEW     = 1
CONST  NOTNEW  = 2

GLOBAL MXLOPT1$
GLOBAL MXLOPT2$
GLOBAL szMXLOPT1$
GLOBAL szMXLOPT2$
GLOBAL APPSELECTED$
GLOBAL DBDRIVER$
GLOBAL PDADRIVER$
GLOBAL PDA$
GLOBAL PDA1$
GLOBAL PDA2$
GLOBAL PDA3$
GLOBAL DB$
GLOBAL DB1$
GLOBAL DB2$
GLOBAL DB3$
GLOBAL DB4$
GLOBAL DB5$
GLOBAL App$
GLOBAL App1$
GLOBAL App2$
GLOBAL App3$
GLOBAL App4$
GLOBAL PILFLAG$
GLOBAL A1$
GLOBAL A2$
GLOBAL A3$
GLOBAL A4$


''CustInst list symbol names
GLOBAL CHK1NEEDS$
GLOBAL CHK2NEEDS$
GLOBAL CHK3NEEDS$
GLOBAL CHK4NEEDS$
GLOBAL CHK5NEEDS$
GLOBAL CHK6NEEDS$
GLOBAL CHK7NEEDS$
GLOBAL EXTRACOSTS$
GLOBAL BIGLIST$

''Dialog list symbol names
GLOBAL CHECKSTATES$
GLOBAL STATUSTEXT$
GLOBAL DRIVETEXT$

Rtn$ = Chr$(13)+Chr$(10)
UPDATENEW%    = NEW

DECLARE SUB AddOptFilesToCopyList (ftype%)
DECLARE SUB RecalcOptFiles (ftype%)
DECLARE SUB RecalcPath
DECLARE SUB SetDriveStatus
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE FUNCTION GetMacroDir1 (szFile$) AS STRING
DECLARE FUNCTION RegForm LIB "pregform.dll" (hWnd%) AS INTEGER
DECLARE FUNCTION GetTickCount LIB "User.exe" () AS LONG
INIT:
    AppName$ = "PackRat"
    CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
    HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
    Handle% = HwndFrame()
    y% = ShowWindow(Handle%, 3)
    hPregForm% = LoadLibrary("PREGFORM.DLL")

    width=GetScreenWidth()
    if width < 641 then
	SetBitmap CUIDLL$, 1
    endif
    
''    if width > 641 then
''        SetBitmap CUIDLL$, 2
''    endif

    SetTitle "PackRat 5.0 Setup"

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

    WINSYSDIR$ = GetWindowsSysDir()
    WINDIR$ = GetWindowsDir()
    WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
    DEST$ = WINDRIVE$ + ":\"+AppName$
    WORDMACRO$ = DEST$
    WPMACRO$   = DEST$
    AMIMACRO$  = DEST$
    EXCELMACRO$ = DEST$

    ''CustInst list symbols
    CHECKSTATES$ = "CheckItemsState"
    STATUSTEXT$  = "StatusItemsText"
    DRIVETEXT$   = "DriveStatusText"
    FOR i% = 1 TO NumOfItems STEP 1
	AddListItem CHECKSTATES$, "ON"
    NEXT i%
    ReplaceListItem CHECKSTATES$, 6, ""         ''Turn Pil Options Off

    FOR i% = 1 TO NumOfItems 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
    CHK1NEEDS$  = "Chk1Needs"
    CHK2NEEDS$  = "Chk2Needs"
    CHK3NEEDS$  = "Chk3Needs"
    CHK4NEEDS$  = "Chk4Needs"
    CHK5NEEDS$  = "Chk5Needs"
    CHK6NEEDS$  = "Chk6Needs"
    CHK7NEEDS$  = "Chk7Needs"
    EXTRACOSTS$ = "ExtraCosts"
    BIGLIST$    = "BigList"
    FOR i% = 1 TO NumOfItems STEP 1
	AddListItem BIGLIST$, ""
    NEXT i%
    FOR i% = 1 TO 26 STEP 1
	AddListItem EXTRACOSTS$, "0"
    NEXT i%

    ''File Option Variables
    sOPTION$ = "{""ON"",""ON""}"
    MXLOPT1$ = "1"
    MXLOPT2$ = "2"
    szMXLOPT1$ = "1"
    szMXLOPT2$ = "2"
    APPSELECTED$ = "{""Word for Windows"",""Excel for Windows"",""AmiPro for Windows"",""WordPerfect for Windows""}"
    APPST1$ = "Word for Windows"
    APPST2$ = "Excel for Windows"
    APPST3$ = "AmiPro for Windows"
    APPST4$ = "WordPerfect for Windows"
    DBDRIVER$ = "{""dBase III+/IV"",""Paradox"",""ASCII"",""Excel"",""Btrieve""}"
    DBST1$ = "dBase III+/IV"
    DBST2$ = "Paradox"
    DBST3$ = "ASCII"
    DBST4$ = "Excel"
    DBST5$ = "Btrieve"
    PDADRIVER$ = "{""Sharp Wizard 7000 Series"",""Sharp Wizard 8000 Series"",""Sharp Wizard 9600 Series""}"
    PDAST1$ = "Sharp Wizard 7000 Series"
    PDAST2$ = "Sharp Wizard 8000 Series"
    PDAST3$ = "Sharp Wizard 9600 Series"
    PDA1$ = "1"
    PDA2$ = "2"
    PDA3$ = "3"
    DB1$  = "1"
    DB2$  = "2"
    DB3$  = "3"
    DB4$  = "4"
    DB5$  = "5"
    App1$ = "1"
    App2$ = "2"
    App3$ = "3"
    App4$ = "4"
    PILFLAG$ = "N"

'$IFDEF DEBUG
    i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
'$ENDIF ''DEBUG

GETUSERNAME:
''      sz$ = UIStartDlg(CUIDLL$, GETNAME, "FNameOrgDlgProc", 0, "")
''      IF sz$ = "CONTINUE" THEN
''          USERNAME$ = GetSymbolValue ("NameOut")
''          IF USERNAME$ = "" THEN
''              i% = DoMsgBox("A Name is required", AppName$, MB_OK+MB_TASKMODAL+MB_ICONHAND)
''              GOTO GETUSERNAME
''          END IF
''          COMPANY$ = GetSymbolValue ("OrgOut")
''          UIPop 1
''      ELSEIF sz$ = "REACTIVATE" THEN
''          GOTO GETUSERNAME
''      ELSE
''          GOSUB ASKQUIT
''          GOTO GETUSERNAME
''      END IF

WELCOME:
    sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
    IF sz$ = "CONTINUE" THEN
	UIPop 1
    ELSE
	GOSUB ASKQUIT
	GOTO WELCOME
    END IF
    n% = DoesIniKeyExist(WINDIR$ + AppName$ +".INI", "Paths", "PackRat")
    IF n% = 1 THEN
	TMP$ = GetIniKeyString(WINDIR$ + Appname$ + ".INI", "Paths","PackRat")
	IF TMP$ <> "" THEN
	  OLDDEST$ = UCASE$(TMP$)
	ENDIF
	IF TMP$ = "" THEN
	  OLDDEST$ = DEST$
	ENDIF
    ENDIF
	RecalcPath
	SetDriveStatus
	GOTO CUSTINST
CUSTINST:
    sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)

    IF sz$ = "CONTINUE" THEN
	''Install only if it will fit.
	FOR i% = 1 TO NumOfItems STEP 1
	    IF GetListItem(BIGLIST$, i%) <> "" THEN
		GOSUB TOOBIG
		GOTO CUSTINST
	    END IF
	NEXT i%
	UIPop 1
	IF ((GetListItem(CHECKSTATES$, PROGRAMFILES) = "ON") OR (GetListItem(CHECKSTATES$, MXLFILES) = "ON") OR (GetListItem(CHECKSTATES$, DBFILES) = "ON") OR (GetListItem(CHECKSTATES$, HELPFILES) = "ON")) THEN
	   IF ((PILFLAG$ = "N") AND GetListItem(CHECKSTATES$, PILFILES)) = "ON" THEN
		App1$ = ""
		App2$ = ""
		App3$ = ""
		App4$ = ""
		GOSUB PILFILES
	   ENDIF
	   GOTO INSTALL
	ELSEIF ((GetListItem(CHECKSTATES$, PDAFILES) = "ON") OR (GetListItem(CHECKSTATES$, SPELLER) = "ON") OR (GetListItem(CHECKSTATES$, PILFILES) = "ON")) THEN
	   IF ((PILFLAG$ = "N") AND GetListItem(CHECKSTATES$, PILFILES)) = "ON" THEN
		App1$ = ""
		App2$ = ""
		App3$ = ""
		App4$ = ""
		GOSUB PILFILES
	   ENDIF
	   GOTO INSTALL
	ELSE
	   i% = DoMsgBox("You must have at least one option checked." , AppName$, MB_OK+MB_TASKMODAL+MB_ICONHAND)
	   GOTO CUSTINST
	ENDIF
    ELSEIF sz$ = "PATH" THEN
	GOTO GETPATH
    ELSEIF sz$ = "CHK1" THEN
	RecalcOptFiles PROGRAMFILES
	SetDriveStatus
	GOTO CUSTINST
    ELSEIF sz$ = "CHK2" THEN
	RecalcOptFiles HELPFILES
	SetDriveStatus
	GOTO CUSTINST
    ELSEIF sz$ = "CHK3" THEN
	IF GetListItem(CHECKSTATES$, MXLFILES) = "ON" THEN
	    sOPTION$ = "{""ON"",""ON""}"
		ENDIF
	RecalcOptFiles MXLFILES
	SetDriveStatus
	GOTO CUSTINST
    ELSEIF sz$ = "BTN3" THEN
	     GOTO MXLFILES
    ELSEIF sz$ = "CHK4" THEN
	RecalcOptFiles PDAFILES
	SetDriveStatus
	GOTO CUSTINST
    ELSEIF sz$ = "BTN4" THEN
	PDA1$ = ""
	PDA2$ = ""
	GOTO PDAFILES
    ELSEIF sz$ = "CHK5" THEN
	RecalcOptFiles SPELLER
	SetDriveStatus
	GOTO CUSTINST
    ELSEIF sz$ = "CHK6" THEN
	RecalcOptFiles PILFILES
	SetDriveStatus
	GOTO CUSTINST
    ELSEIF sz$ = "BTN6" THEN
	App1$ = ""
	App2$ = ""
	App3$ = ""
	App4$ = ""
	PILFLAG$ = "Y"
	GOTO PILFILES
    ELSEIF sz$ = "CHK7" THEN
	RecalcOptFiles DBFILES
	SetDriveStatus
	GOTO CUSTINST
    ELSEIF sz$ = "BTN7" THEN
	DB1$ = ""
	DB2$ = ""
	DB3$ = ""
	DB4$ = ""
	DB5$ = ""
	GOTO DBFILES
    ELSEIF sz$ = "REACTIVATE" THEN
	RecalcPath
	SetDriveStatus
	GOTO CUSTINST
    ELSE
	GOSUB ASKQUIT
	GOTO CUSTINST
    END IF

INSTALL:
    ClearCopyList
    AddOptFilesToCopyList PROGRAMFILES
    AddOptFilesToCopyList HELPFILES
    AddOptFilesToCopyList MXLFILES
    AddOptFilesToCopyList PDAFILES
    AddOptFilesToCopyList SPELLER
    AddOptFilesToCopyList PILFILES
    AddOptFilesToCopyList DBFILES
    IF GetListItem(CHECKSTATES$, PROGRAMFILES) = "ON" THEN
	DirExist% = DoesDirExist(DEST$)
	IF DirExist% = 1 THEN
		i% = DoMsgBox("This directory " + DEST$ +" already exists. Do you want to overwrite it.", AppName$, MB_YESNO+MB_TASKMODAL+MB_ICONHAND)
		IF i% = 7 THEN
			GOTO CUSTINST
		END IF
	END IF
    END IF

    SrcDir$ = GetSymbolValue("STF_SRCDIR")
    CreateDir DEST$, cmoNone
    CreateDir MakePath(DEST$,"backup"), cmoNone
    CreateDir MakePath(DEST$,"macros"), cmoNone
    CreateDir MakePath(DEST$,"bitmaps"), cmoNone
    OpenLogFile MakePath(DEST$,"install.log"),0
    CopyFilesInCopyList
    WinIni$ = MakePath(WINDIR$, "WIN.INI")
    winfax$="1,"+MakePath(DEST$,"PackRat.Exe")+",PackRat,PhoneBook,PackRat"
    CreateIniKeyValue WinIni$, "Sounds", "PackRatAlert", ",PackRat Alert", cmoOverwrite
    CreateIniKeyValue WinIni$, "WfxPbLinks", "PackRat", winfax$, cmoOverwrite

    ini$ = MakePath(WINDIR$, AppName$ +".INI")
    ''402
    IF App3$ = "3" THEN
       AmiIni$ = MakePath(WINDIR$, "AMIPRO.INI")
       CreateIniKeyValue AmiIni$, "AmiPro", "AutoMacroLoad", "1,PIL.SMM", cmoOverwrite
    ENDIF

    IF App4$ = "4" THEN
       WPIni$ = MakePath(WINDIR$, "WPWP.INI")
       CreateIniKeyValue WPIni$, "MacroMenuList", "Save As and Log in PackRat...", MakePath(WPMACRO$,"saveas.wcm"), cmoOverwrite
       CreateIniKeyValue WPIni$, "MacroMenuList", "Save and Log in PackRat...", MakePath(WPMACRO$,"savedoc.wcm"), cmoOverwrite
       CreateIniKeyValue WPIni$, "MacroMenuList", "Find File in PackRat...", MakePath(WPMACRO$,"fileopen.wcm"), cmoOverwrite
       CreateIniKeyValue WPIni$, "MacroMenuList", "Insert PackRat Name...", MakePath(WPMACRO$,"findname.wcm"), cmoOverwrite
       CreateIniKeyValue WPIni$, "MacroMenuList", "Insert PackRat Text...", MakePath(WPMACRO$,"findtext.wcm"), cmoOverwrite
       CreateIniKeyValue WPIni$, "MacroMenuList", "Fax using PackRat...", MakePath(WPMACRO$,"prfax.wcm"), cmoOverwrite
       CreateIniKeyValue WPIni$, "MacroMenuList", "PackRat Financial Report...", MakePath(WPMACRO$,"findexp.wcm"), cmoOverwrite
       CreateIniKeyValue WPIni$, "MacroMenuList", "Insert PackRat Merge Fields...", MakePath(WPMACRO$,"insmerge.wcm"), cmoOverwrite
       CreateIniKeyValue WPIni$, "MacroMenuList", "PackRat Print Merge...", MakePath(WPMACRO$,"prmerge.wcm"), cmoOverwrite
       CreateIniKeyValue WPIni$, "MacroMenuList", "PackRat Integration Help...", MakePath(WPMACRO$,"pilhelp.wcm"), cmoOverwrite
    ENDIF

    RemoveFile MakePath(WINDIR$,"MEMPHIS.INI"),cmoForce

    CreateIniKeyValue ini$, "DBMS", "fAlerts", MakePath(DEST$,"alerts"), cmoOverwrite
    CreateIniKeyValue ini$, "DBMS", "fAttaches", MakePath(DEST$,"attaches"), cmoOverwrite
    CreateIniKeyValue ini$, "DBMS", "fConfig", MakePath(DEST$,"config"), cmoOverwrite
    CreateIniKeyValue ini$, "DBMS", "Open", MakePath(DEST$,"user"), cmoOverwrite
    CreateIniKeyValue ini$, "DBMS", "iSortChars", "10", cmoOverwrite
    CreateIniKeyValue ini$, "DBMS", "iHandles", "50", cmoOverwrite
    CreateIniKeyValue ini$, "DBMS", "bBackup", "Y", cmoOverwrite

    CreateIniKeyValue ini$, "Object Extensions", ";Pxo1", MakePath(DEST$,"DocView.pxo"), cmoOverwrite

    CreateIniKeyValue ini$, "Reporting Extensions", ";rxo1", MakePath(DEST$,"Sample.rxo"), cmoOverwrite

    CreateIniKeyValue ini$, "Macro Extensions", "mxl1", MakePath(DEST$,"PrMacro.mxl"), cmoOverwrite
    CreateIniKeyValue ini$, "Macro Extensions", "; mxl2", MakePath(DEST$,"WinApi.mxl"), cmoOverwrite
    CreateIniKeyValue ini$, "Macro Extensions", "; mxl3", MakePath(DEST$,"PrQeapi.mxl"), cmoOverwrite
    CreateIniKeyValue ini$, "Macro Extensions", "; mxl4", MakePath(DEST$,"PrObj.mxl"), cmoOverwrite

    CreateIniKeyValue ini$, "Drop Extensions", "OpusApp", MakePath(DEST$,"wwdrop.dxf"), cmoOverwrite
    CreateIniKeyValue ini$, "Drop Extensions", "XLMAIN", MakePath(DEST$,"xldrop.dxf"), cmoOverwrite
    CreateIniKeyValue ini$, "Drop Extensions", ";OpusApp", MakePath(DEST$,"wwdropc.dxf"), cmoOverwrite
    CreateIniKeyValue ini$, "Drop Extensions", ";wpwin", MakePath(DEST$,"wpdrop.dxf"), cmoOverwrite
    CreateIniKeyValue ini$, "Drop Extensions", ";qtpro", MakePath(DEST$,"qtpdrop.dxf"), cmoOverwrite
    CreateIniKeyValue ini$, "Drop Extensions", ";amipro", MakePath(DEST$,"ampdrop.dxf"), cmoOverwrite

    CreateIniKeyValue ini$, "Spelling", "CustomDict", MakePath(DEST$,"custom.dic"), cmoOverwrite

    CreateIniKeyValue ini$, "Paths", "Bitmaps", MakePath(DEST$,"bitmaps"), cmoOverwrite
    CreateIniKeyValue ini$, "Paths", "Macros", MakePath(DEST$,"macros"), cmoOverwrite
    CreateIniKeyValue ini$, "Paths", "Speller", MakePath(DEST$,"IENM9150.DAT"), cmoOverwrite
    CreateIniKeyValue ini$, "Paths", "Thesaurus", MakePath(DEST$,"RENTF220.DAT"), cmoOverwrite
    CreateIniKeyValue ini$, "Paths", "PackRat", DEST$, cmoOverwrite
    CreateIniKeyValue ini$, "Paths", "Backup", MakePath(DEST$,"Backup"), cmoOverwrite

    CreateRegKeyValue ".Doc", "WordDocument"
    CreateRegKeyValue "WordDocument\shell\new\command", GetRegKeyValue("WordDocument\shell\open\command")
    CreateRegKeyValue "WordDocument\shell\new\ddeexec", "[FileOpen()][FileSaveAs .Name=""%1""]"
    CreateRegKeyValue ".Sam", "AmiProDocument"
    CreateRegKeyValue "AmiProDocument\shell\new\command", GetRegKeyValue("AmiProDocument\shell\open\command")
    CreateRegKeyValue "AmiProDocument\shell\new\ddeexec", "[New("""",1,0)][SaveAs(""%1"",0,"""","""")]"
    CreateRegKeyValue ".Wp", "WordPerfectDocument"
    CreateRegKeyValue "WordPerfectDocument\shell\new\command", GetRegKeyValue("WordPerfectDocument\shell\open\command")
    CreateRegKeyValue "WordPerfectDocument\shell\new\ddeexec", "[FileNew()][SaveAs(0)]"
    CreateRegKeyValue "WordPerfectDocument\shell\new\ddeexec\application", "WordPerfect"
    CreateRegKeyValue "WordPerfectDocument\shell\new\ddeexec\topic", "Commands"
    CreateRegKeyValue ".xls", "ExcelWorksheet"
    CreateRegKeyValue "ExcelWorksheet\shell\new\command", GetRegKeyValue("ExcelWorksheet\shell\open\command")
    CreateRegKeyValue "ExcelWorksheet\shell\new\ddeexec", "[New(1)][Save.As(""%1"",1)]"
    CreateRegKeyValue "ExcelWorksheet\shell\new\ddeexec\application", "Excel"
    CreateRegKeyValue "ExcelWorksheet\shell\new\ddeexec\topic", "System"

    IF (GetListItem(CHECKSTATES$, PROGRAMFILES) = "ON") THEN
	CreateProgmanGroup "PackRat", "", cmoNone
	ShowProgmanGroup   "PackRat", 1, cmoNone
	CreateProgmanItem  "PackRat", "PackRat 5.0", MakePath(DEST$,"PackRat.exe"), "", cmoOverwrite
	CreateProgmanItem  "PackRat", "ReadMe.txt", "notepad.exe "+MakePath(DEST$,"ReadMe.txt"), "", cmoOverwrite
	CreateProgmanItem  "PackRat", "PackRat Database Utility", MakePath(DEST$,"PdbTools.exe"), "", cmoOverwrite
    ENDIF
QUIT:
    ON ERROR GOTO ERRQUIT

    IF ERR = 0 THEN
	dlg% = EXITSUCCESS
    ELSEIF ERR = STFQUIT THEN
	dlg% = EXITQUIT
    ELSE
	dlg% = EXITFAILURE
    END IF

QUITL1:
    CloseLogFile
    sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
	GOTO QUITL1
    END IF
    UIPop 1
    sz$ = UIStartDlg(CUIDLL$, SUGGEST, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
	GOTO QUITL1
    END IF
    UIPop 1

    IF dlg% = EXITSUCCESS and (GetListItem(CHECKSTATES$, PROGRAMFILES) = "ON") and tmp$="" THEN
	  i% = RegForm(0)
	  Rc% = WinExec(DEST$+"\TELEPRNT.EXE", 2)
	Readme$ = "notepad.exe " + DEST$ + "\" + "readme.txt"
	i% = DoMsgBox("Would you like to view the README file.", AppName$, MB_YESNO+MB_TASKMODAL+MB_ICONINFORMATION)
	IF i% = 6 THEN
		Rc% = WinExec(README$, 1)
	END IF
    END IF
   IF dlg% = EXITSUCCESS and App1$ = "1" AND GetListItem(CHECKSTATES$, PILFILES) = "ON" THEN
	PIL$ = FindFileInTree("WINWORD.EXE", MID$(DEST$, 1, 1)+":\")
	PIL$ = PIL$ + " "+ WORDMACRO$ + "\PIL.DOT"
	Rc% = WinExec(PIL$, 1)
   ENDIF
    i% = FreeLibrary(hPregForm%)
    END

ERRQUIT:
    i% = DoMsgBox("Setup sources were corrupted, Contact Polaris! for assistance", AppName$, MB_OK+MB_TASKMODAL+MB_ICONHAND)
    END

BADPATH:
    sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
	GOTO BADPATH
    END IF
    UIPop 1
    RETURN

ASKQUIT:
    sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")

    IF sz$ = "EXIT" THEN
	UIPopAll
	ERROR STFQUIT
    ELSEIF sz$ = "REACTIVATE" THEN
	GOTO ASKQUIT
    ELSE
	UIPop 1
    END IF
    RETURN

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
	    DEST$ = olddest$
	    GOTO GETPATHL1
	END IF
	UIPop 1

	''Truncate display if too long.
	IF LEN(DEST$) > 23 THEN
	    ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
	ELSE
	    ReplaceListItem DRIVETEXT$, 7, DEST$
	END IF

	''Recalc if path changed.
	IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
	    RecalcPath
	    SetDriveStatus
	END IF

	olddest$ = ""
	GOTO CUSTINST
    ELSEIF sz$ = "BACK" THEN
	RecalcPath
	SetDriveStatus
	UIPop 1
	GOTO CUSTINST
    ELSEIF sz$ = "REACTIVATE" THEN
	RecalcPath
	SetDriveStatus
	GOTO GETPATHL1
    ELSEIF sz$ = "EXIT" THEN
	GOSUB ASKQUIT
	GOTO GETPATHL1
    ELSE
	UIPop 1
	GOTO CUSTINST
    END IF

PDAFILES:
	SetSymbolValue "ListItemsIn", PDADRIVER$
	IF (GetListItem(CHECKSTATES$, PDAFILES) = "ON") THEN
	   SetSymbolValue "ListItemsOut", PDADRIVER$
	ELSE
	   SetSymbolValue "ListItemsOut", ""
	END IF
PDAFILES1:
    sz$ = UIStartDlg(CUIDLL$, MSELECTPDA, "FMultiDlgProc", APPHELP, HELPPROC$)
    newopt$ = GetSymbolValue("ListItemsOut")

    IF sz$ = "CONTINUE" THEN
	    UIPop 1
	    LN = GetListLength("ListItemsOut")
	    FOR L% = 1 TO LN
		PDA$ = GetListItem("ListItemsOut", L%)
		IF PDA$ = PDAST1$ THEN
		  PDA1$ = "1"
		END IF
		IF PDA$ = PDAST2$ THEN
		  PDA2$ = "2"
		END IF
		IF PDA$ = PDAST3$ THEN
		  PDA3$ = "3"
		END IF
	    NEXT

	    IF newopt$ <> "" THEN
		ReplaceListItem CHECKSTATES$, 4, "ON"
	    ELSE
		ReplaceListItem CHECKSTATES$, 4, ""
	    END IF
	    RecalcOptFiles PDAFILES
	    SetDriveStatus
	    newopt$ = ""
	    GOTO CUSTINST
    ELSEIF sz$ = "REACTIVATE" THEN
	RecalcPath
	SetDriveStatus
	GOTO PDAFILES1
    ELSEIF sz$ = "EXIT" THEN
	GOSUB ASKQUIT
	GOTO PDAFILES1
    ELSE
	UIPop 1
	newopt$ = ""
	GOTO CUSTINST
    END IF

PILFILES:
	SetSymbolValue "ListItemsIn", APPSELECTED$
	IF (GetListItem(CHECKSTATES$, PILFILES) = "ON") THEN
	   SetSymbolValue "ListItemsOut", APPSELECTED$
	ELSE
	   SetSymbolValue "ListItemsOut", ""
	END IF
PILFILES1:
    sz$ = UIStartDlg(CUIDLL$, MSELECTPIL, "FMultiDlgProc", APPHELP, HELPPROC$)
    newopt$ = GetSymbolValue("ListItemsOut")

    IF sz$ = "CONTINUE" THEN
	    UIPop 1
	    LN = GetListLength("ListItemsOut")
	    FOR L% = 1 TO LN
		App$ = GetListItem("ListItemsOut", L%)
		IF App$ = APPST1$ THEN
		  App1$ = "1"
		  WORDMACRO$ = GetMacroDir1("WINWORD.EXE")
		END IF
		IF App$ = APPST2$ THEN
		  App2$ = "2"
		  EXCELMACRO$ = GetMacroDir1("EXCEL.EXE")
		END IF
		IF App$ = APPST3$ THEN
		  App3$ = "3"
		  AMIMACRO$ = GetMacroDir1("AMIPRO.EXE")
		END IF
		IF App$ = APPST4$ THEN
		  App4$ = "4"
		  WPMACRO$ = GetMacroDir1("WPWIN.EXE")
		END IF
	    NEXT

	    IF newopt$ <> "" THEN
		ReplaceListItem CHECKSTATES$, 6, "ON"
	    ELSE
		ReplaceListItem CHECKSTATES$, 6, ""
	    END IF
	    RecalcOptFiles PILFILES
	    SetDriveStatus
	    newopt$ = ""
	    IF PILFLAG$ = "Y" THEN
	       GOTO CUSTINST
	    ENDIF
    ELSEIF sz$ = "REACTIVATE" THEN
	RecalcPath
	SetDriveStatus
	GOTO PILFILES1
    ELSEIF sz$ = "EXIT" THEN
	GOSUB ASKQUIT
	GOTO PILFILES1
    ELSE
	UIPop 1
	newopt$ = ""
	IF PILFLAG$ = "Y" THEN
	   GOTO CUSTINST
	ENDIF
    END IF
    RETURN

DBFILES:
	SetSymbolValue "ListItemsIn", DBDRIVER$
	IF (GetListItem(CHECKSTATES$, DBFILES) = "ON") THEN
	   SetSymbolValue "ListItemsOut", DBDRIVER$
	ELSE
	   SetSymbolValue "ListItemsOut", ""
	END IF
DBFILES1:
    sz$ = UIStartDlg(CUIDLL$, MSELECTDB, "FMultiDlgProc", APPHELP, HELPPROC$)
    newopt$ = GetSymbolValue("ListItemsOut")

    IF sz$ = "CONTINUE" THEN
	    UIPop 1
	    LN = GetListLength("ListItemsOut")
	    FOR L% = 1 TO LN
		DB$ = GetListItem("ListItemsOut", L%)
		IF DB$ = DBST1$ THEN
		  DB1$ = "1"
		END IF
		IF DB$ = DBST2$ THEN
		  DB2$ = "2"
		END IF
		IF DB$ = DBST3$ THEN
		  DB3$ = "3"
		END IF
		IF DB$ = DBST4$ THEN
		  DB4$ = "4"
		END IF
		IF DB$ = DBST5$ THEN
		  DB5$ = "5"
		END IF
	    NEXT

	    IF newopt$ <> "" THEN
		ReplaceListItem CHECKSTATES$, 7, "ON"
	    ELSE
		ReplaceListItem CHECKSTATES$, 7, ""
	    END IF
	    RecalcOptFiles DBFILES
	    SetDriveStatus
	    newopt$ = ""
	    GOTO CUSTINST
    ELSEIF sz$ = "REACTIVATE" THEN
	RecalcPath
	SetDriveStatus
	GOTO DBFILES1
    ELSEIF sz$ = "EXIT" THEN
	GOSUB ASKQUIT
	GOTO DBFILES1
    ELSE
	UIPop 1
	newopt$ = ""
	GOTO CUSTINST
    END IF

MXLFILES:
	 IF GetListItem(CHECKSTATES$, MXLFILES) = "ON" THEN
		SetSymbolValue "CheckItemsIn", sOPTION$
	 ELSE
		SetSymbolValue "CheckItemsIn", ""
	 ENDIF
OPT1L1:
    sz$ = UIStartDlg(CUIDLL$, CHECK, "FCheckDlgProc", APPHELP, HELPPROC$)
    newopt$ = GetSymbolValue("CheckItemsOut")

    IF sz$ = "CONTINUE" THEN
	    UIPop 1
	    szMXLOPT1$ = GetListItem("CheckItemsOut",1)
	    x$ = ""

	    IF szMXLOPT1$ = "ON" THEN
		szMXLOPT1$ = "1"
		x$ = "ON"
	    ELSE
		szMXLOPT1$ = ""
	    END IF
	    szMXLOPT2$ = GetListItem("CheckItemsOut",2)
	    IF szMXLOPT2$ = "ON" THEN
		szMXLOPT2$ = "2"
		x$ = "ON"
	    ELSE
		szMXLOPT2$ = ""
	    END IF

	    ReplaceListItem CHECKSTATES$, 3, x$
	    sOPTION$ = newopt$
	    RecalcOptFiles MXLFILES
	    SetDriveStatus
	    newopt$ = ""
	    GOTO CUSTINST
    ELSEIF sz$ = "REACTIVATE" THEN
	RecalcPath
	SetDriveStatus
	GOTO OPT1L1
    ELSEIF sz$ = "EXIT" THEN
	GOSUB ASKQUIT
	GOTO OPT1L1
    ELSE
	UIPop 1
	newopt$ = ""
	GOTO CUSTINST
    END IF

TOOBIG:
    sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
	RecalcPath
	SetDriveStatus
	GOTO TOOBIG
    END IF
    UIPop 1
    RETURN

'** Purpose:
'**     Adds the specified option files to the copy list.
'*************************************************************************
SUB AddOptFilesToCopyList (ftype%) STATIC

    IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
	SrcDir$ = GetSymbolValue("STF_SRCDIR")
	IF ftype% = PROGRAMFILES THEN
	    AddSectionFilesToCopyList "Files", SrcDir$, DEST$
	    AddSectionFilesToCopyList "DLL Files", SrcDir$, DEST$
	    AddSectionKeyFileToCopyList "System Files", "1", SrcDir$, MID$(WINDIR$, 1, LEN(WINDIR$)-1)
	    AddSectionFilesToCopyList "Speller", SrcDir$, DEST$
	    AddSectionFilesToCopyList "Thesaurus", SrcDir$, DEST$

	ELSEIF ftype% = HELPFILES THEN
	    AddSectionFilesToCopyList "Help Files", SrcDir$, DEST$
	ELSEIF ftype% = MXLFILES THEN
	    IF szMXLOPT1$ = MXLOPT1$ THEN
		AddSectionKeyFileToCopyList "MXL Files", szMXLOPT1$, SrcDir$, DEST$
	    END IF
	    IF szMXLOPT2$ = MXLOPT2$ THEN
		AddSectionKeyFileToCopyList "MXL Files", szMXLOPT2$, SrcDir$, DEST$
	    END IF
	ELSEIF ftype% = PDAFILES THEN
	    IF PDA1$ = "1" THEN
		AddSectionKeyFileToCopyList "PDA Files", "1", SrcDir$, DEST$
		AddSectionKeyFileToCopyList "PDA Files", "4", SrcDir$, DEST$
	    END IF
	    IF PDA2$ = "2" THEN
		AddSectionKeyFileToCopyList "PDA Files", "2", SrcDir$, DEST$
		AddSectionKeyFileToCopyList "PDA Files", "4", SrcDir$, DEST$
	    END IF
	    IF PDA3$ = "3" THEN
		AddSectionKeyFileToCopyList "PDA Files", "3", SrcDir$, DEST$
		AddSectionKeyFileToCopyList "PDA Files", "4", SrcDir$, DEST$
	    END IF
	ELSEIF ftype% = SPELLER THEN
''          AddSectionFilesToCopyList "Speller", SrcDir$, DEST$
''          AddSectionFilesToCopyList "Thesaurus", SrcDir$, DEST$
	ELSEIF ftype% = PILFILES THEN
	    AddSectionKeyFileToCopyList "PIL Files", "5", SrcDir$, MID$(WINDIR$, 1, LEN(WINDIR$)-1)
	    AddSectionKeyFileToCopyList "PIL Files", "6", SrcDir$, MID$(WINSYSDIR$, 1, LEN(WINSYSDIR$)-1)

	    IF App1$ = "1" THEN
		IF WORDMACRO$ = "" THEN
			WORDMACRO$=DEST$
		ENDIF
		AddSectionKeyFileToCopyList "PIL Files", "1", SrcDir$, WORDMACRO$
	    END IF
	    IF App2$ = "2" THEN
		IF EXCELMACRO$ = "" THEN
		EXCELMACRO$=DEST$
		ENDIF
		AddSectionKeyFileToCopyList "PIL Files", "2", SrcDir$, EXCELMACRO$
	    END IF
	    IF App3$ = "3" THEN
		IF AMIMACRO$ = "" THEN
		AMIMACRO$=DEST$
		ENDIF

		AddSectionKeyFileToCopyList "PIL Files", "3", SrcDir$, AMIMACRO$
	    END IF
	    IF App4$ = "4" THEN
		IF WPMACRO$ = "" THEN
			WPMACRO$=DEST$
		ENDIF

		AddSectionKeyFileToCopyList "PIL Files", "4", SrcDir$, WPMACRO$
	    END IF
	
	
	ELSEIF ftype% = DBFILES THEN
		dbexist%=DoesFileExist(WINSYSDIR$+"QELIB.DLL",femExists)
	
		if dbexist% then
			currdate$ = GetDateOfFile(WINSYSDIR$+"QELIB.DLL")
		endif

		if dbexist% and a$="" and currdate$ > "1993-02-10-10-26-32" then
			a$="ALREADY SET TO COPY"
			copyit%=DoMsgBox("Setup Found a newer Version of QELIB.DLL on your system, copy our version of the Q+E Files?", AppName$, MB_YESNO+MB_TASKMODAL+MB_ICONHAND)
			if copyit%=6 then
				COPYDB%=1
			End if
		Elseif dbexist%=0 OR dbexist% and currdate$ < "1993-02-10-10-26-33" then
			COPYDB%=1
		END IF

		if COPYDB% then
			IF DB1$ = "1" THEN
				AddSectionKeyFileToCopyList "DB Files", "3", SrcDir$, MID$(WINSYSDIR$, 1, LEN(WINSYSDIR$)-1)
			END IF
			IF DB2$ = "2" THEN
				AddSectionKeyFileToCopyList "DB Files", "4", SrcDir$, MID$(WINSYSDIR$, 1, LEN(WINSYSDIR$)-1)
			END IF
			IF DB3$ = "3" THEN
				AddSectionKeyFileToCopyList "DB Files", "5", SrcDir$, MID$(WINSYSDIR$, 1, LEN(WINSYSDIR$)-1)
			END IF
			IF DB4$ = "4" THEN
				AddSectionKeyFileToCopyList "DB Files", "6", SrcDir$, MID$(WINSYSDIR$, 1, LEN(WINSYSDIR$)-1)
			END IF
			IF DB5$ = "5" THEN
				AddSectionKeyFileToCopyList "DB Files", "1", SrcDir$, MID$(WINSYSDIR$, 1, LEN(WINSYSDIR$)-1)
			END IF
			AddSectionKeyFileToCopyList "DB Files", "2", SrcDir$, MID$(WINSYSDIR$, 1, LEN(WINSYSDIR$)-1)
		end if
	END IF
	SrcDir$ = ""
    END IF
END SUB

'*************************************************************************
SUB RecalcOptFiles (ftype%) STATIC
    CursorSave% = ShowWaitCursor()
    ClearCopyList
    AddOptFilesToCopyList ftype%

    fExtra% = 0
    IF ftype% = PROGRAMFILES THEN
	ListSym$ = CHK1NEEDS$
	IF GetListItem(CHECKSTATES$, PROGRAMFILES) = "ON" THEN
	    ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
	    ReplaceListItem EXTRACOSTS$, ndrive%, "9192"
	    fExtra% = 1
	END IF
    ELSEIF ftype% = HELPFILES THEN
	ListSym$ = CHK2NEEDS$
	IF GetListItem(CHECKSTATES$, HELPFILES) = "ON" THEN
	    ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
	    ReplaceListItem EXTRACOSTS$, ndrive%, "0"
	    fExtra% = 1
	END IF
    ELSEIF ftype% = MXLFILES THEN
	ListSym$ = CHK3NEEDS$
	IF GetListItem(CHECKSTATES$, MXLFILES) = "ON" THEN
	    ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
	    ReplaceListItem EXTRACOSTS$, ndrive%, "0"
	    fExtra% = 1
	END IF
    ELSEIF ftype% = PDAFILES THEN
	ListSym$ = CHK4NEEDS$
	IF GetListItem(CHECKSTATES$, PDAFILES) = "ON" THEN
	    ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
	    ReplaceListItem EXTRACOSTS$, ndrive%, "0"
	    fExtra% = 1
	END IF
    ELSEIF ftype% = SPELLER THEN
	ListSym$ = CHK5NEEDS$
	IF GetListItem(CHECKSTATES$, SPELLER) = "ON" THEN
	    ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
	    ReplaceListItem EXTRACOSTS$, ndrive%, "0"
	    fExtra% = 1
	END IF
    ELSEIF ftype% = PILFILES THEN
	ListSym$ = CHK6NEEDS$
	IF GetListItem(CHECKSTATES$, PILFILES) = "ON" THEN
	    ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
	    ReplaceListItem EXTRACOSTS$, ndrive%, "0"
	    fExtra% = 1
	END IF
    ELSEIF ftype% = DBFILES THEN
	ListSym$ = CHK7NEEDS$
	IF GetListItem(CHECKSTATES$, DBFILES) = "ON" THEN
	    ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
	    ReplaceListItem EXTRACOSTS$, ndrive%, "0"
	    fExtra% = 1
	END IF
    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

'*************************************************************************
SUB RecalcPath STATIC

    CursorSave% = ShowWaitCursor()

    RecalcOptFiles PROGRAMFILES
    RecalcOptFiles HELPFILES
    RecalcOptFiles MXLFILES
    RecalcOptFiles PDAFILES
    RecalcOptFiles SPELLER
    RecalcOptFiles PILFILES
    RecalcOptFiles DBFILES

    RestoreCursor CursorSave%
END SUB

'**
SUB SetDriveStatus STATIC

    drive$ = MID$(DEST$, 1, 1)
    ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
    cost& = VAL(GetListItem(CHK1NEEDS$, ndrive%)) + VAL(GetListItem(CHK2NEEDS$, ndrive%)) + VAL(GetListItem(CHK3NEEDS$, ndrive%))
    cost& = cost& + VAL(GetListItem(CHK4NEEDS$, ndrive%)) + VAL(GetListItem(CHK5NEEDS$, ndrive%))
    cost& = cost& + VAL(GetListItem(CHK6NEEDS$, ndrive%)) + VAL(GetListItem(CHK7NEEDS$, 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(CHK1NEEDS$, ndrive%)) + VAL(GetListItem(CHK2NEEDS$, ndrive%)) + VAL(GetListItem(CHK3NEEDS$, ndrive%)) + VAL(GetListItem(CHK4NEEDS$, ndrive%))
	cost& = cost& + VAL(GetListItem(CHK5NEEDS$, ndrive%)) + VAL(GetListItem(CHK6NEEDS$, ndrive%)) + VAL(GetListItem(CHK7NEEDS$, ndrive%))
	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

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

FUNCTION GetMacroDir1 (szFile$) STATIC AS STRING
    hPrev% = ShowWaitCursor()
    WP$ = ""
    WP$ = FindFileInTree(szFile$, MID$(DEST$, 1, 1)+":\")
    WP$ = StripPath (WP$)
    IF WP$ <> "" THEN
	IF App1$ = "1" THEN
	   SetSymbolValue "EditTextIn", WP$
	ENDIF
	IF App2$ = "2" THEN
	   SetSymbolValue "EditTextIn", WP$+"\XLSTART"
	ENDIF
	IF App3$ = "3" THEN
	   SetSymbolValue "EditTextIn", WP$+"\MACROS"
	ENDIF
	IF App4$ = "4" THEN
	   SetSymbolValue "EditTextIn", WP$+"\MACROS"
	ENDIF
	SetSymbolValue "EditFocus", "END"
    ELSE
	SetSymbolValue "EditTextIn", DEST$
    END IF
    RestoreCursor(hPrev%)
	IF App1$ = "1" THEN
	   IF A1$<>"1" THEN
	   sz$ = UIStartDlg(CUIDLL$, GETWORDMACRODIR, "FEditDlgProc", APPHELP, HELPPROC$)
	   A1$="1"
	   ENDIF
	ENDIF
	IF App2$ = "2" THEN
	   IF A2$<>"1" THEN
	   sz$ = UIStartDlg(CUIDLL$, GETEXCELMACRODIR, "FEditDlgProc", APPHELP, HELPPROC$)
	   A2$="1"
	   ENDIF
	ENDIF
	IF App3$ = "3" THEN
	   IF A3$<>"1" THEN
	   sz$ = UIStartDlg(CUIDLL$, GETAMIMACRODIR, "FEditDlgProc", APPHELP, HELPPROC$)
	   A3$="1"
	   ENDIF
	ENDIF
	IF App4$ = "4" THEN
	   IF A4$<>"1" THEN
	   sz$ = UIStartDlg(CUIDLL$, GETWPMACRODIR, "FEditDlgProc", APPHELP, HELPPROC$)
	   A4$="1"
	   ENDIF
	ENDIF
    IF sz$ = "CONTINUE" THEN
	WP$ = GetSymbolValue("EditTextOut")
	GetMacroDir1 = WP$
	UIPop 1
    ELSEIF sz$ = "EXIT" THEN
	UIPop 1
    ELSE
	UIPop 1
    END IF
END FUNCTION
