[GRASS-user] distance from extent to origin cost surfaces

Hamish hamish_b at yahoo.com
Tue Apr 1 22:50:52 EDT 2008


[feel free to cut away gratuitous quoted text folks...]

Dylan wrote:
> I need a little help understanding this little bit from the original
> code:
> 
> if (!G_is_d_null_value(c))
>           {
>            out_row[col] = opt.new->answer
>                           ? newval
>                           : *c;
>            break;
>           }
> 
> what exactly is this stanza doing, and why does it contain newval
> *and* opt.new->answer ??


result = (if_this_is_true) ? then_set_result_to_this : otherwise_this

In this case it tests to see if the new= "new value" option was given, in
the case of a flag this is directly true or false. In the case of an
option= (as here), the test is to see if the answer is NULL, ie if the
user used that option on the command line or not. If they didn't use it
and it doesn't have a default answer, it will be NULL.

So this code tests to see if the new= option was given, and if it was it
uses the value given for that option, otherwise it uses the value of the
cell, which has just been confirmed as non-null.


Hamish



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com



More information about the grass-user mailing list