Friday, February 8, 2008

Docs: How to understand JGrass's console engine - part III, how to use it?

1) Java scripting through beanshell

The easiest start is always playing a bit around. open the console and write some simplified java code, as reported in the image below.


To execute the script right-click and choose run from the menu. The result of the script will be seen in the output window.

2) grass commands execution

Commands wrapped by


grass {

}

are interpreted as native grass commands and executed like that. Just use the GRASS syntax.

See below the example of the execution of the help of the g.region command.


3) the JGrass modeling language based on OpenMI

Same as for GRASS commands, JGrass commands are wrapped inside


jgrass {

}


The JGrass modeling language will need a larger article, so I don't even dare to talk about it now in this short space.

However, have a look at the shot below, showing a mixed script between GRASS, JGrass and beanshell, passing variables from one language to the other, gaining return values from the JGrass models. This all gives the possibility to easily create also complex algorythm without having to know the development framework... no compilation... just write and execute!


2 comments:

Anonymous said...

if i am trying

grass {
g.region --help
}

i get the following error message

-------------------------------- Compiling... ---------------------------------
untitled.jgrass
untitled.jgrass(16) : error E3105: missing native model identifier before 'g.region'.
untitled.jgrass - 1 model/s compiled, total compilation time: 31 ms

-------------------------------------------------------------------------------
Beanshell, Version 2.0b4, Copyright (C) Pat Niemeyer
------------------------------ Running model... -------------------------------

what i am doing wrong?

moovida said...

Hi, there could be several issues bound to that problem, I would need to have more informations. We use the mailinglist for problems like those, so that others can exploit the solution. Would you mind to send this to the mailinglist? Thanks