[GRASS-user] return value of modules?

Hi

do the modules of R (e.g. r.stats, ...) have return values which I can
evaluate to find out if the execution was successful? E.g. returning
-1 when an error occurred?

I would like to use these "return values on error" to evaluate the
success of the command when called from R.

Thanks,

Rainer

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Faculty of Science
Natural Sciences Building
Private Bag X1
University of Stellenbosch
Matieland 7602
South Africa

Rainer Krug wrote:

do the modules of R (e.g. r.stats, ...) have return values
which I can evaluate to find out if the execution was successful?

Yes. GRASS modules all return 0 on success and 1 on failure.

I would like to use these "return values on error" to evaluate the
success of the command when called from R.

In most cases you can trust that method. Maybe 1% of modules use a
different failure code, if so it's a bug & please report it.

Some/many of the internal C functions will use 1 as success, but they
will typically be called G_is_something() and return a boolean result.
The lib fns return all sorts of things, always check before using them.

Hamish

On Fri, Sep 19, 2008 at 11:42 AM, Hamish <hamish_b@yahoo.com> wrote:

Rainer Krug wrote:

do the modules of R (e.g. r.stats, ...) have return values
which I can evaluate to find out if the execution was successful?

Yes. GRASS modules all return 0 on success and 1 on failure.

Good to know - thanks as lot

Rainer

I would like to use these "return values on error" to evaluate the
success of the command when called from R.

In most cases you can trust that method. Maybe 1% of modules use a
different failure code, if so it's a bug & please report it.

Some/many of the internal C functions will use 1 as success, but they
will typically be called G_is_something() and return a boolean result.
The lib fns return all sorts of things, always check before using them.

Hamish

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Faculty of Science
Natural Sciences Building
Private Bag X1
University of Stellenbosch
Matieland 7602
South Africa