The Script Editor

In the template editor it is possible to select a script as executable code.
In other words you can write the code used to calculate a function in form of a script. Matrex includes by default the Jython interpreter and there are plugins for JRuby and Groovy.

To make things, Matrex includes a script editor which is actually a small IDE. It allows you to:
In this way you can be reasonably sure that the script will work when used to calculate matrices in a project.

To create or edit a script select the application menu System -> Edit Scripts. The following window appears:



Script Editor

The editor is on the top right side of the IDE.
It supports a limited syntax highlighting (only keywords, operators and special characters) but it is confortable for writing scripts, that in general should not be larger than a hundreds lines.
You can:
Writing a script means writing the code for the calculation class which inherits from IFunction (as you do in java).

Once your script is written, you can test it using the views on the right side of the window:
Once all matrices and parameters are in place, you can execute it using the Run button in the toolbar.
The output of the script (print...) is written in the output view on the window's left bottom side.
If the script has errors, the errors are also writtent in the output view, in red.

If the script has success, it populates the output matrices, which can be viewed.

To save the script, press the Save button on the top. If the script is new this display a save dialog to give a path/name to the script file. If the script was only edited it is saved without requesting a name/path, because it already has it.
The Save As button saves the script always requesting its name/path.

To know how to write Jython code, go to the site www.jython.org.
To know how to write a Matrex function, read the document “Matrex Function Coding”.