home *** CD-ROM | disk | FTP | other *** search
- // GTCTLFL.SCP - Sample Script function to return the location of a specified control data file.
- // Copyright (c) 2000, Vector Networks Limited
- // All Rights Reserved
- //
- // Revision History:
- // 5.3 19-Jul-00 AB - Created.
-
- // GetControlFile uses GetControlDir so it must be included with the following statement
-
- $INCLUDE "GTCTLDIR.SCP"
-
- Function GetControlFile (FName as String, Pfile as String) as String
- Dim t, Reg, RegKey, RegSubKey, RegValue, FLc, Result
-
- // Initialise an error result
-
- Result = ""
-
- // If no profile is passed to the function then use the standard profile
-
- if Pfile = "" then Pfile = "Standard"
-
- // Work out which registry key to open.
-
- RegKey = "SOFTWARE\Productive Computer Insight\PCICtl\ConfigList\" + Pfile
-
- // Work out which file is required
-
- Print "Searching Profile ", Pfile, " for file ", FName
- FName = LCase (FName)
-
- if FName = "client.nsm" then RegSubkey = "Files\ClientFile"
- if FName = "group.nsm" then RegSubkey = "Files\GroupFile"
- if FName = "remote.nsm" then RegSubkey = "Files\RemoteFile"
- if FName = "scripts.nsm" then RegSubkey = "Files\ScriptsFile"
- if FName = "tools.nsm" then RegSubkey = "Files\ToolsFile"
-
- // If an invalid file name had been supplied, produce an error. If not, continue.
-
- If RegSubkey != "" then
-
- // Open the registry key
-
- Reg = RegOpenKey (HKEY_LOCAL_MACHINE, RegKey)
-
- // Get the file location from the registry
-
- If Reg then
- Print "Registry Key ", RegKey, " opened"
-
- RegValue = Trim (RegGetValue (Reg, RegSubKey, t))
-
- // Close the registry key.
-
- RegCloseKey (Reg)
- Endif
-
- // If the file path does not include a directory path, add the
- // Control's install directory. Otherwise, leave it alone.
-
- If IsString (RegValue) AND Len (RegValue) > 0 Then
- Print "Registry Value ", RegSubKey, " contains ", RegValue
- If InStr (RegValue, "\") != 0 then
- Result = RegValue
- Else
- Result = Trim (GetControlDir ()) + "\" + RegValue
- Endif
- Else
- Result = Trim (GetControlDir ()) + "\" + FName
- Endif
- Else
-
- // If a wrong file name is supplied, produce this error
-
- Print "Invalid file name: " + FName
- endif
-
- Print "Control file location: ", Result
-
- // Return the result
-
- GetControlFile = Result
- End Function
-