The GetRegistryValue method returns a value from the Windows Registry. Since Stonefield Query stores its user settings in the Registry, and any additional options you define in an Options.Setting script are also stored there, this method is useful if you need to determine the value of a setting.

Syntax

GetRegistryValue(ValueName as String, DefaultValue as String, 
  Node as String) as String

Parameters
ValueName
The name of the value in the Registry.

DefaultValue
The value to return if the name isn't found in the Registry. Optional: if this parameter isn't specified, a blank string is returned.

Node
The name of the node in the Registry that the value can be found in. If this parameter isn't passed, the value is looked for in HKEY_CURRENT_USER\Software\CompanyName\ApplicationName\Options (where CompanyName and ApplicationName are the values of the Company Name and Application Name configuration settings). If a value is passed and it doesn't contain a backslash (\), that node is used instead of Options. For example, specifying "Data" means that HKEY_CURRENT_USER\Software\CompanyName\ApplicationName\Data is used. If it does contain a backslash, then it must be a complete path to any place in the Registry, such as HKEY_LOCAL_MACHINE\Software\Whatever\SomeNode.

Return Value
The value in the Registry if it was found or DefaultValue if not.

Example
Here's an example that uses some custom options settings defined in an Options.Settings script. If the "Report on AR data" option is No, all AR tables are marked as not reportable. If the option is Yes, then the "Location of AR data" setting is used as the location for the AR tables. This code goes into the DataEngine.GetCustomMetaData script.

Visual FoxPro

lparameters toApplication as SQApplication
local lcValue, lcLocation, lnI, loTable as Table
lcValue = toApplication.GetRegistryValue('AR Data')
lcLocation = toApplication.GetRegistryValue('AR Location')
for lnI = 1 to toApplication.DataEngine.Tables.Count
  loTable = toApplication.DataEngine.Tables.Item(lnI)
  do case
    case left(loTable.Alias, 2) <> 'AR'
    case lcValue = 'Y'
      loTable.Location = lcLocation
    otherwise
      loTable.Reportable = .F.
  endcase
next

VBScript

function Main(Application)
dim Table
Value = Application.GetRegistryValue("AR Data")
Location = Application.GetRegistryValue("AR Location")
for I = 1 to Application.DataEngine.Tables.Count
  set Table = Application.DataEngine.Tables.Item(I)
  if left(Table.Alias, 2) = "AR" then
    if Value = "Y" then
      Table.Location = Location
    else
      Table.Reportable = False
    end if
  end if
next
end function

JavaScript

function Main(Application) {
var Value, Location, I, Table ;
Value = Application.GetRegistryValue('AR Data') ;
Location = Application.GetRegistryValue('AR Location') ;
for (I = 1; I <= Application.DataEngine.Tables.Count; I++) {
  Table = Application.DataEngine.Tables.Item(I) ;
  if (left(Table.Alias, 2) = 'AR') {
    if (Value = 'Y') {
      Table.Location = Location ;
      }
    else {
      Table.Reportable = false ;
      }
  }
}
}

See Also
Application Object | SetINIValue | SetRegistryValue