If you set the Need Target Application Directory configuration setting to True, the first time the user runs Stonefield Query, it prompts them to specify the location of the target application. If you want to ensure that the user selected the correct directory, create some code for the Application.ValidateTargetAppDir script, such as checking for the existence of the main executable file for the application. Return False from the script if the selected directory is invalid. You can control the warning message displayed to the user if the directory is invalid by setting the Message for Invalid Target App Directory configuration setting.

Parameters
A reference to the Stonefield Query Application object and the directory chosen by the user (terminated with a backslash).

Return Value
True if the directory the user selected is the correct one.

Example
Here's an example that checks if MYAPP.EXE can be found in the directory the user selected.

Visual FoxPro

lparameters toApplication as SQApplication, tcDirectory
return file(tcDirectory + 'myapp.exe')

VBScript

function Main(Application, Directory)
dim fso
set fso = CreateObject("Scripting.FileSystemObject")
Main = fso.FileExists(Directory & "myapp.exe")
end function

JavaScript

function Main(Application, Directory) {
var fso, Found ;
fso = new ActiveXObject('Scripting.FileSystemObject') ;
Found = fso.FileExists(Directory + 'myapp.exe')
return Found ;
}

C#

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

public static bool Application_ValidateTargetAppDir(SFQApplication sfqApplication, string directory)
{
  return !File.Exists(directory + "myapp.exe");
}

VB.NET

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

public shared function Application_ValidateTargetAppDir(sfqApplication as SFQApplication, directory as string) as Boolean
  return Not File.Exists(directory + "myapp.exe")
End Function

See also

Application.GetDefaultTargetAppDir | Application.ValidateCommonDir | Message for Invalid Target App Directory | Need Target Application Directory | Scripts

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