[GRASS-dev] [grass.script.core] parser() casts options as strings
Glynn Clements
glynn at gclements.plus.com
Fri Jul 31 16:10:05 EDT 2009
Martin Landa wrote:
> > The ->answer field in "struct Option" is a char*; it can only hold a
> > string. Similarly, that's all that g.parser can pass to a script. It's
> > up to the module or script to parse these to integers or floats where
> > appropriate.
>
> would make sense to change it in GRASS 7, e.g. option->answer as
> 'union' (int, double, char *).
opt->answer can also be a list of values when opt->multiple == TRUE.
> In this regard also check given value
> by the parser. Then the parser could print a warning when the user
> enter option value which cannot be casted to the given data type (e.g.
> string for integer option).
It already does this; see check_an_opt() in parser.c.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list