Script Snippet
Gather Data and Perform Calculations
The Script Snippet is the Snippet to compute data or gather information from the executing program. Feedback-writing programs developed in the ESF Edit are executed by other programs that use the ESF Runtime. In order to generate the individual feedback, the information provided by the executing program (e.g., LMSA Kit) must be retrieved. In some cases, further calculations must be performed before the information has been processed to the extent that they can be used in simple conditions by IfElse Snippets.
A right-click on the Script Snippet opens its function menu. The first entry starts the script editor of the Snippet. The opening script editor shows the script that is already stored in the Script Snippet. It can be written directly into the input field, but the menu can also load finished scripts or save the current script for later use.
Perform Calculations
The script can be entered in the upper text field. The language for scripts should be easy to understand for beginners, so it is very much based on mathematical equations. It is easy to do calculations.
Simple terms can be entered and are calculated. However, it makes little sense to make calculations with constant values, they can already be calculated in advance. The strength of the Script Snippet lies in calculating with variables. Variables are placeholders that can take any value. They can be set by calculations and they can be used in calculations. Variables are strings that have been marked as variables by a variable marker char.
There are two types of variables:
- local variables: They are declared as variables by a simple, prefixed "$". This variable only exists in the current Script Snippet and does not exist outside. This is useful, for example, if only intermediate results should be stored briefly.
- global variables: They are declared as variables by a double, prefixed "$". This variable can be retrieved and used in any project Script Snippet and If Snippet.
The $ is important before the name of a variable, otherwise the string is considered as plain text. Texts can not be used for calculations; otherwise an error is triggered.
Gather Data
In order to access the data provided by the executing program, it is necessary to make use of the additional functions provided by it. Programmers can register their own functions in the ESF Runtime, which can be called from scripts. Therefore, no general introduction, how to get to this data, can be given here. As an example, here are the commands run and arg, which are provided by the LMSA Kit to the ESF Runtime. Run launches an analysis in the LMSA Kit and arg can then search the data fields of the report.
The use of functions provided by the executing application can be very complex. For known applications, therefore, there is an auxiliary system in the ESF Edit that supports you when creating these commands. Further information can be found in the corresponding section under Useful Hints.