[GRASSLIST:367] Re: G_gisinit

Glynn Clements glynn at gclements.plus.com
Fri Mar 24 11:09:26 EST 2006


Ana Soares wrote:

>  int G_gisinit (char *program_name)initialize gis libraryThis routine reads
> the user's GRASS environment file into memory and makes sure that the user
> has selected a valid database and mapset. It also initializes hidden
> variables used by other routines. If the user's database information is
> invalid, an error message is printed and the module exits. The *program_name
> * is stored for later recall by *G_program_name.* It is recommended that
> argv[0] be used for the *program_name
> *
> 
> *Ok.
> *
> 
> *So I use it  in my program, like :
> *
> 
> * int main(int argc, char **argv) {
> 
>    G_gisinit(argv[0]) ;
> }
> 
> *
> 
> And the program just stands there :-S
> 
> I'm really confused! After all, what does this function do ?

It checks that the GRASS environment is set up correctly, and
initialises some important variables.

> How am I supposed to use it?

Like the above. Then you need to use G_define_{module,flag,option}
followed by G_parser(). What happens after that depends upon your
program, but all GRASS modules start with a common framework involving
G_gisinit() and G_parser().

Look at doc/raster/r.example or doc/vector/v.example for examples of
how to write GRASS modules.

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




More information about the grass-user mailing list