home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Demo / PCDUO / data1.cab / Script_Samples / GTCTLFL.SCP < prev    next >
Encoding:
Text File  |  2003-11-28  |  2.5 KB  |  84 lines

  1. // GTCTLFL.SCP - Sample Script function to return the location of a specified control data file.
  2. // Copyright (c) 2000, Vector Networks Limited
  3. // All Rights Reserved
  4. //
  5. // Revision History:
  6. // 5.3 19-Jul-00 AB - Created.
  7.  
  8. // GetControlFile uses GetControlDir so it must be included with the following statement
  9.  
  10. $INCLUDE "GTCTLDIR.SCP"
  11.  
  12. Function GetControlFile (FName as String, Pfile as String) as String
  13.     Dim t, Reg, RegKey, RegSubKey, RegValue, FLc, Result
  14.  
  15.     // Initialise an error result
  16.  
  17.     Result = ""
  18.  
  19.     // If no profile is passed to the function then use the standard profile
  20.  
  21.     if Pfile = "" then Pfile = "Standard"
  22.  
  23.     // Work out which registry key to open.
  24.  
  25.     RegKey = "SOFTWARE\Productive Computer Insight\PCICtl\ConfigList\" + Pfile
  26.  
  27.     // Work out which file is required
  28.  
  29.     Print "Searching Profile ", Pfile, " for file ", FName
  30.     FName =  LCase (FName)
  31.  
  32.     if FName = "client.nsm" then RegSubkey = "Files\ClientFile"
  33.     if FName = "group.nsm" then RegSubkey = "Files\GroupFile"
  34.     if FName = "remote.nsm" then RegSubkey = "Files\RemoteFile"
  35.     if FName = "scripts.nsm" then RegSubkey = "Files\ScriptsFile"
  36.     if FName = "tools.nsm" then RegSubkey = "Files\ToolsFile"
  37.  
  38.     // If an invalid  file name had been supplied, produce an error.  If not, continue.
  39.  
  40.     If RegSubkey != "" then
  41.  
  42.         // Open the registry key
  43.  
  44.         Reg = RegOpenKey (HKEY_LOCAL_MACHINE, RegKey)
  45.  
  46.         // Get the file location from the registry
  47.  
  48.         If Reg then
  49.             Print "Registry Key ", RegKey, " opened"
  50.  
  51.             RegValue = Trim (RegGetValue (Reg, RegSubKey, t))
  52.     
  53.             // Close the registry key.
  54.  
  55.             RegCloseKey (Reg)
  56.         Endif
  57.  
  58.         //  If the file path does not include a directory path, add the 
  59.         //  Control's install directory. Otherwise,  leave it alone.
  60.  
  61.         If IsString (RegValue) AND Len (RegValue) > 0 Then
  62.             Print "Registry Value ", RegSubKey, " contains ", RegValue
  63.             If InStr (RegValue, "\") != 0 then 
  64.                 Result = RegValue
  65.             Else
  66.                 Result = Trim (GetControlDir ()) + "\" + RegValue
  67.             Endif
  68.         Else
  69.             Result = Trim (GetControlDir ()) + "\" + FName
  70.         Endif
  71.     Else
  72.  
  73.         // If a wrong file name is supplied, produce this error
  74.  
  75.         Print "Invalid file name: " + FName
  76.     endif
  77.  
  78.     Print "Control file location: ", Result
  79.  
  80.     // Return the result
  81.  
  82.     GetControlFile = Result
  83. End Function
  84.