The Execute method runs an application. You can specify an application name or the name of a file associated with the application. For example, calling Execute with a URL launches the user's default browser and navigates to that URL. This method is a wrapper for the Windows ShellExecute function.
Syntax
Execute(FileName as String [, Operation as String
[, WorkingDirectory as String [, Parameters as String]]]) as Integer
Parameters
FileName
The fully-qualified path for the application to execute, the fully-qualified path for the file to open in the associated application, a URL, etc..
Operation
The operation to perform on the file, such as "Open" (the default if this parameter isn't specified) or "Print".
WorkingDirectory
The directory to make the current one for the application.
Parameters
Additional parameters to pass to the application.
Return Value
The return value from ShellExecute. Values over 32 indicate success and return an instance handle for the application. Some common values are:
- 2: file was not found
- 3: path was not found
- 31: no application association
See http://support.microsoft.com/kb/238245 for other values.
Example
Here's an example, taken from the topic for linking to Google Maps, which opens a URL in a browser window.
Visual FoxPro
lparameters tcFieldName, tuValue
local lcLocation, lcURL
* If this is a "discovery" call, return the fields needed in the result set.
* The leading "*" means all of these fields are needed in the result set and
* the "action parameter" combo box should not be displayed. In that case, the
* first field after the "*" is the field to pass to this code for the "action"
* call.
if empty(tcFieldName)
return '*,Customers.CustomerID,Customers.Address,Customers.City,' + ;
'Customers.Region,Customers.PostalCode,Customers.Country'
else
* tuValue contains the CustomerID for the customer the user clicked on. We need
* to use that to lookup the Address, City, Region, Postal Code, and Country
* fields.
locate for CustomerID = tuValue and not empty(City)
lcLocation = trim(Address) + ',' + trim(City) + ',' + trim(Region) + ',' + ;
trim(PostalCode) + ',' + trim(Country)
* Append the location info to the base Google Maps URL and bring it up in a
* browser window.
lcURL = 'http://maps.google.com/maps?&hl=en&q=' + lcLocation
SQApplication.Execute(lcURL, 'Open')
endif
See also
Application Object© Stonefield Software Inc., 2024 • Updated: 01/02/19
Comment or report problem with topic