This script is called when the user changes the value of a custom option setting (which is defined in an Options.Settings script) in the Options dialog. It allows you to ensure the value entered by the user is valid.

If your Options.Settings and Setup.Settings scripts are the same, you may wish to use the same code you have in Options.Validate in a Setup.Validate 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.Validate and Setup.Validate.

Parameters
A reference to the Stonefield Query Application object, the Registry or INI key for the custom option as defined in the Options.Settings script, and the value entered by the user.

Return Value
The text of an error message if the value is invalid or an empty string if it is valid.

Example
Here's an example that ensures the directory setting indicating the location of the AR data is valid.

Visual FoxPro

lparameters toApplication as SQApplication, tcKey, tuValue
local lcMessage
lcMessage = ''
if tcKey = 'AR Location' and not file(tuValue + 'AR.DBF')
  lcMessage = 'That directory does not contain the AR data file.'
endif
return lcMessage

VBScript

function Main(Application, Key, Value)
dim fso
set fso = CreateObject("Scripting.FileSystemObject")
Main = ""
if Key = "AR Location" and not fso.FileExists(Value & "AR.DBF") then
  Main = "That directory does not contain the AR data file."
end if
end function

JavaScript

function Main(Application, Key, Value) {
var Message, fso ;
Message = '' ;
fso = new ActiveXObject('Scripting.FileSystemObject') ;
if (Key = 'AR Location' && ! fso.FileExists(Value + 'ar.dbf')) {
  Message = 'That directory does not contain the AR data file.'
}
return(Message) ;
}

C#

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

public static string Options_Validate(SFQApplication sfqApplication, 
  string key, object value)
{	
  string message = String.Empty;
  if(key == "AR Location" && !File.Exists(value + "ar.dbf"))
  {
    message = "That directory does not contain the AR data file.";
  }
  return message;
}

VB.NET

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

public shared function Options_Validate(sfqApplication as SFQApplication,
  key as string, value as object) as string
  Dim message As String = String.Empty
  if(key = "AR Location" And Not File.Exists(value + "ar.dbf"))
    message = "That directory does not contain the AR data file."
  End if
  return message
End Function

See also

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