About working with tool return values
The geoprocessor always returns the output values of the tool when it is executed. The return value is an object. Typically, this object is the path to the output dataset produced or updated by the tool, but it can be other value types, such as a number or Boolean. If an output for a tool is a multivalue parameter, the values are returned in a string, which consists of multiple strings separated by a semicolon.
Output values are always returned to the program from the geoprocessor. Return values are necessary when a tool has no output dataset; instead, it has an output scalar value, such as an integer or Boolean. Return values are also helpful when working with multiuser databases, since output names are qualified with a user's name and table space when outputs are written into the database. The following code examples show how return values are captured and what the values can be.
- The following code example shows the return path to output data:
// The return value is a string that is the path to the output. String returnval = (String)gp.execute(bufferTool, null);
- The following code example shows the return value for a multivalue:
// The return value is an object of type double. String defgrid = (String)gp.execute(calculateDefaultGridIndex, null);
- The following code example shows returning a GeoProcessorResult:
// The return value is the path to the output. IGeoProcessorResult result = gp.Execute(calculateGridIndexTool, null); Object defgrid = result.getReturnValue();