This script is called when the user clicks the OK button in the Options dialog if you've defined any custom options settings in an Options.Settings script. It gives you an opportunity to do something about the changes, such as storing a value in another location.

If your Options.Settings and Setup.Settings scripts are the same, you may wish to use the same code you have in Options.Changed in a Setup.Changed script. The best way to do that is to create a user-defined script with the necessary code and call that script from both Options.Changed and Setup.Changed.

A reference to the Stonefield Query Application object and an XML string containing the key values, former values, and new values of all custom options. The format for the XML is as follows:

        <key>Registry key</key>
        <old>Former value</old>
        <new>New value</new>
        <key>Registry key</key>
        <old>Former value</old>
        <new>New value</new>

The following elements are available:

  • key: the Registry key under HKEY_CURRENT_USER\Software\CompanyName\ApplicationName\Options (where CompanyName and ApplicationName are the values of the Company Name and Application Name configuration settings) that holds the value for the setting. Alternatively, if you're storing values in Data.INI, this is the key value under the Options section.

  • old: the former value for this option.

  • new: the value entered by the user.

Return Value
Any value (Stonefield Query ignores the return value).

Here's an example that updates a custom property of the Application object when a change is made to the custom AR Location setting.

Visual FoxPro

lparameters toApplication as SQApplication, tcSettingsXML
local loXMLDOM as MSXML.DOMDocument, loNodes, loNode, lcDirectory
loXMLDOM = createobject('MSXML.DOMDocument')
loXMLDOM.ASync = .F.
loNodes = loXMLDOM.selectNodes('/settings/setting')
for each loNode in loNodes
  if loNode.childNodes(0).text = 'AR Location'
    lcDirectory = loNode.childNodes(2).text
toApplication.ARLocation = lcDirectory


function Main(Application, SettingsXML)
dim XMLDOM, Nodes, Node
set XMLDOM = createobject("MSXML.DOMDocument")
XMLDOM.ASync = False
set Nodes = XMLDOM.selectNodes("/settings/setting")
for each Node in Nodes
  if Node.childNodes(0).text = "AR Location" then
    Directory = Node.childNodes(2).text
    exit for
  end if
toApplication.ARLocation = Directory
end function


function Main(Application, SettingsXML) {
var XMLDOM, Nodes, Node, Directory ;
XMLDOM = new ActiveXObject('MSXML.DOMDocument') ;
XMLDOM.ASync = false ;
XMLDOM.LoadXML(SettingsXML) ;
Nodes = XMLDOM.selectNodes("/settings/setting") ;
for (Node in Nodes)
  if (Node.childNodes(0).text == "AR Location")
    Directory = Node.childNodes(2).text ;
    break ;
Application.ARLocation = Directory ;
return ;


Please note that the method in this script must be named Options_Changed.

public static void Options_Changed(SFQApplication sfqApplication,
  string settingsXML)
    string directory = String.Empty;
    XmlDocument doc = new XmlDocument();
    XmlNodeList nodes = doc.SelectNodes("/settings/setting");

    foreach (XmlNode node in nodes)
        if (node.ChildNodes[0].InnerText == "AR Location")
            directory = node.ChildNodes[2].InnerText;
            sfqApplication.SetProperty("ARLocation", directory);


Please note that the method in this script must be named Options_Changed.

public shared function Options_Changed(sfqApplication as SFQApplication,
  settingsXML as string) as Boolean

    Dim directory As String = String.Empty
    Dim doc As XmlDocument = New XmlDocument()

    Dim nodes As XmlNodeList = doc.SelectNodes("/settings/setting")

    For Each node As XmlNode In nodes

        If node.ChildNodes(0).InnerText = "AR Location" Then
            directory = node.ChildNodes(2).InnerText
            sfqApplication.SetProperty("ARLocation", directory)
        End If

    Return True
End Function

See the topic for the GetRegistryValue method of the Application object for an example that uses these options.

See also

Options.Settings | Options.Validate | Scripts | Setup.Changed

© Stonefield Software Inc., 2023 • Updated: 06/06/16
Comment or report problem with topic