User Tools

Write a script with Groovy


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

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
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


capsis -p groovy bin\maddmodule\myscripts\maddscript.groovy


sh -p groovy bin/maddmodule/myscripts/maddscript.groovy
documentation/groovy.txt · Last modified: 2013/05/23 10:25 (external edit)