[GRASSLIST:361] G_gisinit

Hello

I’ve a problem : I use G_gisinit but I’m having some trouble understanding it

From what I’ve read :

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 ? How am I supposed to use it?

Thanks :slight_smile:

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@gclements.plus.com>

I’m sorry, but I still don’t understand :frowning: Can someone explain this to me ?

Thanks.

2006/3/24, Glynn Clements <glynn@gclements.plus.com>:

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@gclements.plus.com>