[GRASS-dev] still problems with overwrite in scripts
Glynn Clements
glynn at gclements.plus.com
Thu Jun 28 11:43:10 PDT 2012
Michael Barton wrote:
> My question was about testing for the overwrite flag. But I did try
> this, as I mentioned in my post to Glynn and get an error wherever I
> put it. I tried in the string option for output prefix first, of
> course. But when that didn't work, I tried in the input and
> pull-down for sharpening algorithm too. No luck anywhere. If it only
> works in an option specified by G_OPT_R_OUTPUT and G_OPT_V_OUTPUT
> automatically generates and overwrite flag box without adding it, it
> seems kind of redundant. Shrug.
The "overwrite" setting goes in the module section (along with
keywords), not the options/flags sections.
In C (this is from r.mapcalc):
module = G_define_module();
G_add_keyword(_("raster"));
G_add_keyword(_("algebra"));
module->description = _("Raster map calculator.");
module->overwrite = 1;
In Python (there aren't any scripts which currently require this
feature, so this is contrived):
#%module
#% description: This is a script
#% keywords: script
#% overwrite: yes
#%end
It only works in 7.0. In 6.x, g.parser won't recognise the overwrite
setting, and using it in C will force the overwrite setting on due to
bug #1658.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list