|
DarrenF
Using an INI file to point to your HF Classic data files... November 26, 2010 01:11PM |
// Setup var for processing INI file
gproviINIResult is int
gprovsFolder is string
// Handle the INI file for Network drive location
IF fDirectoryExist(fExeDir()) THEN
// If INI file exists then read the 'Drive' entry
IF fFileExist(fExeDir + "\System.INI") THEN
// If found, then read it
gprovsFolder = INIRead("NetworkDrive","Drive","",fExeDir + "\System.INI")
ELSE
// INI file not found, so browse for network drive
gprovsFolder = UserSelectDataDir()
// Test for no folder selected
IF gprovsFolder = "" THEN
// Error already reported in UserSelectDataDir, so get out of here
EndProgram()
ELSE
// Directory selected, so Create/Write INI file entry
gproviINIResult = INIWrite("NetworkDrive","Drive",gprovsFolder,fExeDir + "\System.INI")
END
END
ELSE
// Directory doesn't already exist, so create DIR
fMakeDir(fExeDir())
// INI file not found, so browse for network drive
gprovsFolder = UserSelectDataDir()
// Test for no folder selected
IF gprovsFolder = "" THEN
// Error already reported in UserSelectDataDir, so get out of here
EndProgram()
ELSE
// Directory selected, so Create/Write INI file entry
gproviINIResult = INIWrite("NetworkDrive","Drive",gprovsFolder,fExeDir + "\System.INI")
END
END
// Now swap to the drive selected...
HChangeDir("*",gprovsFolder)
PROCEDURE UserSelectDataDir()
glocalsDataFolder is string
// Browse for network drive
glocalsDataFolder = fSelectDir("", "Select a directory...", "I can't seem to locate your data files. Please select the server network directory that contains your data files OR, if this is your server, select the local directory that contains the data files.", "")
// Test for no folder selected
IF glocalsDataFolder = "" THEN
Error("You must select a local or network folder to continue!","Please re-run the system.",...
"If this problem persists or you are not able to select the required folder, then please contact your system administrator for help.")
END
// Return the folder (blank or otherwise)
RESULT glocalsDataFolder