[GRASS-user] r.mapcalc: Syntax Error?

Glynn Clements glynn at gclements.plus.com
Thu Apr 5 14:20:15 EDT 2012


Rich Shepard wrote:

>    GRASS reports a syntax error running r.mapcalc that I do not see:
> 
> GRASS 6.5.svn (Washington-Kinross):~/grassdata > r.mapcalc "weight =
> if(tan_curv_5.lm < 0, -100 * tan_curv_5.lm, \
> if(tan_curv_7.lm < 0, -100 * tan_curv_7.lm, \
> if(tan_curv_11.lm < 0, -100 * tan_curv_11.lm, 0.000001)))"
> syntax error, unexpected ';'
> Parse error
> [Raster MASK present]
> 
>    Since there is no semi-colon in the command, what is grass trying to tell
> me?

Pretend that it said "unexpected newline".

The parser translates a newline (when not preceded by a backslash) to
a semicolon, so newline and semicolon can be used interchangeably as
statement separators. By the time the parser notices the syntax error,
the translation has already occurred,

If there is a newline after the "=", that would explain the syntax
error.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list