documentation:groovy
Write a script with Groovy
Introduction
Groovy is a high level scripting language based on Java. Its syntax is similar but very simpler thus allowing to write scripts very quickly.
Using groovy with Capsis
From the Capsis main graphical user interface
- Open the groovy console
Menu tools→Groovy Console
- Upper part is used to write groovy code
- Lower part shows script output
Exemple
import capsis.script.C4Script import capsis.kernel.Step; import capsis.kernel.Engine; import maddmodule.script.* // Simple use of the maddmodule s = new C4Script("maddmodule") s.init(new MaddInitialParameters (s.getModel(), s.getDataDir() + "/maddmodel/A.inv")) result = s.evolve(new MaddEvolutionParameters (200)) // Display scenario in Capsis s.updateGUI();
Launch Capsis directly with the Groovy pilot
Groovy scripts can be executed directly from the command line without starting the capsis GUI. The scripts are compiled on the fly.
Convention : groovy script should be placed in the myscripts
directory
Windows
capsis -p groovy bin\maddmodule\myscripts\maddscript.groovy
Linux
sh capsis.sh -p groovy bin/maddmodule/myscripts/maddscript.groovy
documentation/groovy.txt · Last modified: 2021/12/13 09:28 by 127.0.0.1