'**************************************************************************
'*                       MSSetup for RDM for Windows v2.5
'*
'*      Last Modified:  12/13/94 cl
'**************************************************************************

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

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

''Dialog ID's
CONST WELCOME      = 100
CONST ASKQUIT      = 200
CONST DESTPATH     = 300
CONST EXITFAILURE  = 400
CONST EXITQUIT     = 600
CONST EXITSUCCESS  = 700
CONST OPTIONS      = 800
CONST APPHELP      = 900
CONST NETHELP      = 1200
CONST NETHELP2     = 1400
CONST SINGLELIST   = 1900
CONST CHECK        = 2500
CONST CUSTINST     = 6200
CONST TOOBIG       = 6300
CONST BADPATH      = 6400

''Bitmap ID
CONST LOGO         = 1

''File Types
CONST RDMFILES      = 1
CONST WVRVWFILES    = 2

''Dialog Box Constants
CONST MB_YESNO      = 4
CONST IDYES         = 6
CONST IDNO          = 7


GLOBAL DEST$        ''Default destination directory.
GLOBAL WINDRIVE$    ''Windows drive letter.
GLOBAL OPT1OPT$     ''Option selection from OptFiles1 option dialog.
GLOBAL OLD_PWDFILE$ ''Place to save old password file if it exists.
GLOBAL OLD_INSTANCE$
GLOBAL OLD_WORKAREA$
GLOBAL OLD_APPLAUNCH$
GLOBAL OLD_REPORT$
GLOBAL OLD_PLRVW$
GLOBAL OLD_WVAREA$
GLOBAL OLD_HOST$

''CustInst list symbol names
GLOBAL APPNEEDS$    ''Option list costs per drive
GLOBAL OPT1NEEDS$
GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)

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


DECLARE SUB AddOptFilesToCopyList (ftype%)
DECLARE SUB RecalcOptFiles (ftype%)
DECLARE SUB RecalcPath
DECLARE SUB SetDriveStatus
DECLARE SUB ModVaultEntry (VaultDLL$)
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE SUB SavePswdFile
DECLARE SUB RestorePswdFile


INIT:
    CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
    HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure

    SetBitmap CUIDLL$, LOGO
    SetTitle "RDM for Windows v2.5 Installation"

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

    WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
    DEST$ = WINDRIVE$ + ":\RDM2.5"
    OPTCUR$ = "1"

WELCOME:
    sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
    IF sz$ = "CONTINUE" THEN
	UIPop 1
    ELSE
	GOSUB ASKQUIT
	GOTO WELCOME
    END IF

OPTION:
    ''CustInst list symbols
    CHECKSTATES$ = "CheckItemsState"
    STATUSTEXT$  = "StatusItemsText"
    DRIVETEXT$   = "DriveStatusText"
    FOR i% = 1 TO 2 STEP 1
	AddListItem CHECKSTATES$, "ON"
    NEXT i%
    FOR i% = 1 TO 2 STEP 1
	AddListItem STATUSTEXT$, ""
    NEXT i%
    FOR i% = 1 TO 8 STEP 1
	AddListItem DRIVETEXT$, ""
    NEXT i%
    ReplaceListItem DRIVETEXT$, 7, DEST$

    ''Disk cost list symbols
    APPNEEDS$   = "AppNeeds"
    OPT1NEEDS$  = "Opt1Needs"
    EXTRACOSTS$ = "ExtraCosts"
    BIGLIST$    = "BigList"
    FOR i% = 1 TO 2 STEP 1
	AddListItem BIGLIST$, ""
    NEXT i%
    FOR i% = 1 TO 26 STEP 1
	AddListItem EXTRACOSTS$, "0"
    NEXT i%

    ''File Option Variables
    OPT1OPT$ = "1"

    RecalcPath
    SetDriveStatus

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



CUSTINST:
    sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)

    IF sz$ = "CONTINUE" THEN
	''Install only if it will fit.
	FOR i% = 1 TO 2 STEP 1
	    IF GetListItem(BIGLIST$, i%) <> "" THEN
		GOSUB TOOBIG
		GOTO CUSTINST
	    END IF
	NEXT i%
	UIPop 1
	GOTO INSTALL
    ELSEIF sz$ = "PATH" THEN
	GOTO GETPATH
    ELSEIF sz$ = "CHK1" THEN
	RecalcOptFiles RDMFILES
	SetDriveStatus
	GOTO CUSTINST
    ELSEIF sz$ = "CHK2" THEN
	RecalcOptFiles WVRVWFILES
	SetDriveStatus
	GOTO CUSTINST
    ELSEIF sz$ = "REACTIVATE" THEN
	RecalcPath
	SetDriveStatus
	GOTO CUSTINST
    ELSE
	GOSUB ASKQUIT
	GOTO CUSTINST
    END IF



INSTALL:
    SavePswdFile
    ClearCopyList
    AddOptFilesToCopyList RDMFILES
    AddOptFilesToCopyList WVRVWFILES
    CopyFilesInCopyList

    GOSUB GETNET

    OpenLogFile MakePath(DEST$, "RDMINST.LOG"), 0
    WriteToLogFile ""
    WriteToLogFile "  RDM for Windows v2.5 Installation Log"
    WriteToLogFile ""
    WriteToLogFile "  User chose as RDM destination directory: '" + DEST$ + "'"
    WriteToLogFile ""
    WriteToLogFile "  Options chosen were: "
    IF GetListItem(CHECKSTATES$, 1) = "ON" THEN
	WriteToLogFile "	RDM for Windows"
    END IF
    IF GetListItem(CHECKSTATES$, 2) = "ON" THEN
	WriteToLogFile "	RDM WorldView Review"
    END IF
    WriteToLogFile ""
    WriteToLogFile "  The following Network option was enabled:"
    WriteToLogFile ""
    WriteToLogFile "	" + NETTYPE$
    WriteToLogFile ""
    WriteToLogFile "  May have had to create the directory: " + DEST$
    WriteToLogFile ""

' Setup RDM directories and Application Groups for Windows

    IF GetListItem(CHECKSTATES$, RDMFILES) = "ON" THEN
	CreateDir DEST$, cmoNone
	CreateDir MakePath(DEST$,"bin"), cmoNone
	CreateDir MakePath(DEST$,"data\msg"), cmoNone
	CreateDir MakePath(DEST$,"help\english"), cmoNone     
	CreateDir MakePath(DEST$,"help\english\rdmonlin"), cmoNone
	CreateDir MakePath(DEST$,"ui"), cmoNone
	CreateDir MakePath(DEST$,"windows"), cmoNone
	CreateProgmanGroup "Interleaf", "", cmoNone
	ShowProgmanGroup  "Interleaf", 1, cmoNone
	CreateProgmanItem "Interleaf", "RDM v2.5", MakePath(DEST$,"bin\rdmjam.exe")+" rdm", ",,,,"+MakePath(DEST$,"ui"), cmoOverwrite
	CreateProgmanItem "Interleaf", "RDM v2.5 Read Me", MakePath(GetWindowsDir(),"notepad.exe")+" readme.txt", ",,,,"+DEST$, cmoOverwrite

'$IFDEF    REG_DB_ENABLED
    CreateRegKeyValue "RDM", "Relational Document Manager"
'$ENDIF '' REG_DB_ENABLED
    END IF

    IF GetListItem(CHECKSTATES$, WVRVWFILES) = "ON" THEN
	IF GetListItem(CHECKSTATES$, RDMFILES) = "OFF" THEN
	    CreateDir DEST$, cmoNone
	    CreateDir MakePath(DEST$,"bin"), cmoNone
	END IF
	CreateProgmanGroup "Interleaf", "", cmoNone
	ShowProgmanGroup  "Interleaf", 1, cmoNone
	CreateProgmanItem "Interleaf", "WorldView Review", MakePath(DEST$,"bin\wvreview.exe"), "", cmoOverwrite
    END IF

    WriteToLogFile ""

    WriteToLogFile "  Please make sure the following steps are performed before"
    WriteToLogFile "  starting RDM for Windows for the first time:"
    WriteToLogFile ""
    WriteToLogFile "  Note: This is not necessary if you only selected" 
    WriteToLogFile "        WorldView Review."
    WriteToLogFile ""
    WriteToLogFile "  Modify the file AUTOEXEC.BAT and add the following line:"
    WriteToLogFile "      set SMININAMES=English.ini"
    WriteToLogFile ""
    WriteToLogFile "  Note: English may be replaced with French or German,"
    WriteToLogFile "        depending on your Unix/VMS language selection."
    WriteToLogFile ""
    WriteToLogFile "  Modify the file "+Makepath(GetWindowsDir(),"RDM.INI")+" and"
    WriteToLogFile "  set the values as appropriate for your site."
    WriteToLogFile ""
    RdmIni$ = MakePath (GetWindowsDir, "rdm.ini")
    CreateIniKeyValue RdmIni$, "Rdm", "RDM_PASSWORD_FILE", MakePath(DEST$,"BIN\RDMPSWD.FTP"), cmoOverwrite
    IF OLD_PWDFILE$ <> "" THEN
	RestorePswdFile
	WriteToLogFile "  The existing RDM password for this workstation called"
	WriteToLogFile "  "+OLD_PWDFILE$+" has been copied to "+MakePath(DEST$,"BIN")
    ELSE
	WriteToLogFile "  Make sure that your RDM password file is created with"
	WriteToLogFile "  the RDMCRYPT utility as specified in the Installation Guide."
    END IF
    CreateIniKeyValue RdmIni$, "Rdm", "RDM_HOME", DEST$, cmoOverwrite
    CreateIniKeyValue RdmIni$, "Rdm", "RDM_HELP_DIR", MakePath(DEST$,"HELP\ENGLISH"), cmoOverwrite
    CreateIniKeyValue RdmIni$, "Jam Options", "SMPATH", MakePath(DEST$,"UI"), cmoOverwrite
    CreateIniKeyValue RdmIni$, "Jam Options", "SMVARS", MakePath(DEST$,"UI\SMVARS.BIN"), cmoOverwrite
    WriteToLogFile ""
    CloseLogFile

QUIT:
    ON ERROR GOTO ERRQUIT

    IF ERR = 0 THEN
	dlg% = EXITSUCCESS
    ELSEIF ERR = STFQUIT THEN
	dlg% = EXITQUIT
    ELSE
	dlg% = EXITFAILURE
    END IF
QUITL1:
    sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
    IF sz$ = "REACTIVATE" THEN
	GOTO QUITL1
    END IF
    UIPop 1

    END

ERRQUIT:
    i% = DoMsgBox("Setup sources were corrupted, please call Interleaf Customer Support for assistance!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
    END


GETNET:
    LISTITEM$ = "ListItemsIn"           ''list of supported networks
    AddListItem LISTITEM$, "FTP PC/TCP v2.2"
    AddListItem LISTITEM$, "NetManage Chameleon v3.11"
    AddListItem LISTITEM$, "Winsock v1.1 compliant"
    AddListItem LISTITEM$, "Winsock v1.1 (non-async)"
''    AddListItem LISTITEM$, "Pathworks v5 (DECnet)" 
    sz$ = UIStartDlg(CUIDLL$, SINGLELIST, "FListDlgProc", NETHELP2, HELPPROC$)
    IF sz$ = "CONTINUE" OR sz$ = "EXIT" THEN
	nettype$ = GetSymbolValue("ListItemsOut")
	IF nettype$ = "" THEN
	    GOSUB NEEDNET
	    GOTO GETNET
	END IF
    END IF
    IF nettype$ = "NetManage Chameleon v3.11" THEN
	CopyFile MakePath(DEST$,"bin\rdmftpn.dll"), MakePath(DEST$,"bin\rdmftp.dll"), cmoOverwrite, 0
	RenameFile MakePath(DEST$,"bin\ftp.dll"), "ftpd.dll"
    ELSEIF nettype$ = "Winsock v1.1 compliant" THEN
	CopyFile MakePath(DEST$,"bin\rdmftpd.dll"), MakePath(DEST$,"bin\rdmftp.dll"), cmoOverwrite, 0
    ELSEIF nettype$ = "Winsock v1.1 (non-async)" THEN
	CopyFile MakePath(DEST$,"bin\rdmftpw.dll"), MakePath(DEST$,"bin\rdmftp.dll"), cmoOverwrite, 0
    ELSEIF nettype$ = "Pathworks v5 (DECnet)" THEN
	CopyFile MakePath(DEST$,"bin\rdmftpp.dll"), MakePath(DEST$,"bin\rdmftp.dll"), cmoOverwrite, 0
	ModVaultEntry MakePath(DEST$,"bin\vltdnet.dll")
    ELSE
	CopyFile MakePath(DEST$,"bin\rdmftpf.dll"), MakePath(DEST$,"bin\rdmftp.dll"), cmoOverwrite, 0
    END IF
RETURN

NEEDNET:
    i% = DoMsgBox("You must select one of the available options before continuing.", "Network Selection", MB_OK+MB_TASKMODAL+MB_ICONHAND)
    RETURN

GETPATH:
    SetSymbolValue "EditTextIn", DEST$
    SetSymbolValue "EditFocus", "END"
GETPATHL1:
    sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)

    IF sz$ = "CONTINUE" THEN
	olddest$ = DEST$
	DEST$ = GetSymbolValue("EditTextOut")

	''Validate new path.
	IF IsDirWritable(DEST$) = 0 THEN
	    GOSUB BADPATH
	    GOTO GETPATHL1
	END IF
	UIPop 1

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

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

	olddest$ = ""

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



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



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


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

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



'**
'** Purpose:
'**     Adds the specified option files to the copy list.
'** Arguments:
'**     ftype%  - type of files to add, any of the following:
'**             RDMFILES, WVRVWFILES
'** Returns:
'**     none.
'*************************************************************************
SUB AddOptFilesToCopyList (ftype%) STATIC

    IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
	SrcDir$ = GetSymbolValue("STF_SRCDIR")
	IF ftype% = RDMFILES THEN
	    AddSectionFilesToCopyList "Rdm", SrcDir$, DEST$
	    AddSectionFilesToCopyList "RdmBin", SrcDir$, MakePath(DEST$,"bin")
	    AddSectionFilesToCopyList "RdmDataMsg", SrcDir$, MakePath(DEST$,"data\msg")
	    AddSectionFilesToCopyList "RdmHelp", SrcDir$, MakePath(DEST$,"help\english")
	    AddSectionFilesToCopyList "RdmHelpDoc", SrcDir$, MakePath(DEST$,"help\english\rdmonlin")
	    AddSectionFilesToCopyList "RdmUi", SrcDir$, MakePath(DEST$,"ui")
	    AddSectionFilesToCopyList "RdmWin", SrcDir$, GetWindowsDir
	END IF
	IF ftype% = WVRVWFILES THEN
	    AddSectionFilesToCopyList "WvRvwBin", SrcDir$, MakePath(DEST$,"bin")
	    IF GetListItem(CHECKSTATES$, 1) = "OFF" THEN
		AddSectionFilesToCopyList "RdmWin", SrcDir$, GetWindowsDir
	    END IF
	END IF
	SrcDir$ = ""
    END IF
END SUB


'**
'** Purpose:
'**     Recalculates disk space for the given option files and sets
'**     the status info symbol "StatusItemsText".
'** Arguments:
'**     ftype% - type of files to add, any of the following:
'**             RDMFILES, WVRVWFILES
'** Returns:
'**     none.
'*************************************************************************
SUB RecalcOptFiles (ftype%) STATIC
    CursorSave% = ShowWaitCursor()
    ClearCopyList
    AddOptFilesToCopyList ftype%

    fExtra% = 0
    IF ftype% = RDMFILES THEN
	ListSym$ = APPNEEDS$
	IF GetListItem(CHECKSTATES$, RDMFILES) = "ON" THEN
	    ''Add extra cost to Windows drive for ini/progman, etc.
	    ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
	    ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
	    fExtra% = 1
	END IF
    END IF
    IF ftype% = WVRVWFILES THEN
	ListSym$ = OPT1NEEDS$
    END IF

    StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")

    cost& = 0
    FOR i% = 1 TO 26 STEP 1
	cost&  = cost& + VAL(GetListItem(ListSym$, i%))
    NEXT i%
    ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"

    IF StillNeed& > 0 THEN
	ReplaceListItem BIGLIST$, ftype%, "YES"
    ELSE
	ReplaceListItem BIGLIST$, ftype%, ""
    END IF

    IF fExtra% THEN
	ReplaceListItem EXTRACOSTS$, ndrive%, "0"
    END IF

    RestoreCursor CursorSave%
    ListSym$ = ""
END SUB


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

    CursorSave% = ShowWaitCursor()

    RecalcOptFiles RDMFILES
    RecalcOptFiles WVRVWFILES

    RestoreCursor CursorSave%
END SUB


'**
'** Purpose:
'**     Sets drive status info according to latest disk space calcs.
'** Arguments:
'**     none.
'** Returns:
'**     none.
'*************************************************************************
SUB SetDriveStatus STATIC

    drive$ = MID$(DEST$, 1, 1)
    ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
    cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%))
    free& = GetFreeSpaceForDrive(drive$)
    ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
    ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
    ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"

    IF drive$ = WINDRIVE$ THEN
	ReplaceListItem DRIVETEXT$, 4, ""
	ReplaceListItem DRIVETEXT$, 5, ""
	ReplaceListItem DRIVETEXT$, 6, ""
    ELSE
	ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
	cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%))
	IF cost& = 0 THEN
	    ReplaceListItem DRIVETEXT$, 4, ""
	    ReplaceListItem DRIVETEXT$, 5, ""
	    ReplaceListItem DRIVETEXT$, 6, ""
	ELSE
	    free& = GetFreeSpaceForDrive(WINDRIVE$)
	    ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
	    ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
	    ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
	END IF
    END IF
END SUB


'**
'** Purpose:
'**     Appends a file name to the end of a directory path,
'**     inserting a backslash character as needed.
'** Arguments:
'**     szDir$  - full directory path (with optional ending "\")
'**     szFile$ - filename to append to directory
'** Returns:
'**     Resulting fully qualified path name.
'*************************************************************************
FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
    IF szDir$ = "" THEN
	MakePath = szFile$
    ELSEIF szFile$ = "" THEN
	MakePath = szDir$
    ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
	MakePath = szDir$ + szFile$
    ELSE
	MakePath = szDir$ + "\" + szFile$
    END IF
END FUNCTION

'*************************************************************************
'**
'** Purpose:
'**     Change Vault DLL entry in RDM.INI to accomodate DECnet vault
'**     method (PCDNET).
'**
'*************************************************************************
SUB ModVaultEntry (VaultDLL$) STATIC
    RdmIni$ = MakePath (GetWindowsDir, "rdm.ini")
    IF DoesIniKeyExist(RdmIni$, "AddOns", "VaultMethods") = 0 THEN
	CreateIniKeyValue RdmIni$, "AddOns", "VaultMethods", VaultDLL$, cmoOverwrite
    ELSE
	i% = DoMsgBox("Could not file RDM.INI file. You must manually update the RDM_VLTMTHDS_DLL file", "DECnet Setup", MB_OK+MB_TASKMODAL+MB_ICONHAND)
    END IF
END SUB

'*************************************************************************
'**
'** Purpose:
'**     Save and restore RDM password file if one already exists from a
'**     previous install of this software.
'**
'*************************************************************************
SUB SavePswdFile STATIC
    RdmIni$ = MakePath (GetWindowsDir, "rdm.ini")
    IF DoesFileExist(RdmIni$, femRead) = 1 THEN
	OLD_PWDFILE$ = GetIniKeyString (RdmIni$, "Rdm", "RDM_PASSWORD_FILE")
	OLD_INSTANCE$ = GetIniKeyString (RdmIni$, "Rdm", "RDM_INSTANCE")
	OLD_WORKAREA$ = GetIniKeyString (RdmIni$, "Rdm", "RDM_WORK_AREA")
	OLD_APPLAUNCH$ = GetIniKeyString (RdmIni$, "Rdm", "RDM_APPLICATION_LAUNCH")
	OLD_REPORT$ = GetIniKeyString (RdmIni$, "Rdm", "RDM_REPORT_NAME")
	OLD_PLRVW$ = GetIniKeyString (RdmIni$, "Rdm", "RDM_PL_REVIEW")
	OLD_WVAREA$ = GetIniKeyString (RdmIni$, "Rdm", "RDM_WV_AREA")
	OLD_HOST$ = GetIniKeyString (RdmIni$, "Rdm", "RDM_HOST")
    END IF
END SUB

SUB RestorePswdFile STATIC
    RdmIni$ = MakePath (GetWindowsDir, "rdm.ini")
    IF DoesFileExist(RdmIni$, femRead) = 1 THEN
	NEW_PWDFILE$ = GetIniKeyString (RdmIni$, "Rdm", "RDM_PASSWORD_FILE")
    END IF
    IF MID$(OLD_PWDFILE$, 2, 1) <> ":" THEN
	OLD_PWDFILE$ = WINDRIVE$ + ":" + OLD_PWDFILE$
    END IF
    IF DoesFileExist(OLD_PWDFILE$, femRead) = 1 THEN
	CopyFile OLD_PWDFILE$, NEW_PWDFILE$, cmoOverwrite, 0
    ELSE
	OLD_PWDFILE$ = ""
    END IF
    IF OLD_HOST$ <> "" THEN
	CreateIniKeyValue RdmIni$, "Rdm", "RDM_HOST", OLD_HOST$, cmoOverwrite
    END IF
    IF OLD_INSTANCE$ <> "" THEN
	CreateIniKeyValue RdmIni$, "Rdm", "RDM_INSTANCE", OLD_INSTANCE$, cmoOverwrite
    END IF
    IF OLD_WORKAREA$ <> "" THEN
	CreateIniKeyValue RdmIni$, "Rdm", "RDM_WORK_AREA", OLD_WORKAREA$, cmoOverwrite
    END IF
    IF OLD_APPLAUNCH$ <> "" THEN
	CreateIniKeyValue RdmIni$, "Rdm", "RDM_APPLICATION_LAUNCH", OLD_APPLAUNCH$, cmoOverwrite
    END IF
    IF OLD_REPORT$ <> "" THEN
	CreateIniKeyValue RdmIni$, "Rdm", "RDM_REPORT_NAME", OLD_REPORT$, cmoOverwrite
    END IF
    IF OLD_PLRVW$ <> "" THEN
	CreateIniKeyValue RdmIni$, "Rdm", "RDM_PL_REVIEW", OLD_PLRVW$, cmoOverwrite
    END IF
    IF OLD_WVAREA$ <> "" THEN
	CreateIniKeyValue RdmIni$, "Rdm", "RDM_WV_AREA", OLD_WVAREA$, cmoOverwrite
    END IF
END SUB
