The inputs of the tool are defined by the inputParameters
parameter. Input values can be accessed in the script code through
an object called
$i in the global scope. For example, if there is
an input parameter called
input, its value is stored in
inputParameters: A table that defines input parameters. The first column contains the name of a parameter, the second one its type (optional/required/fixed) and the third one the data type of the parameter’s value.
outputParameters: A table that defines output parameters. The first column contains the name of the parameter, the second one is type (synchronous/asynchronous) and the third one the data type of the parameter’s value.
stateEnabled: Whether the script code supports state variables or not. It may have a slight impact on performance, so if the script does not need state variables, it is advisable not to enable this parameter.
The outputs of the tool are defined by the outputParameters
parameter. Output values can be accessed in the script code through
an object called
$o in its scope. For example, if there is an
output parameter called
output, it can be assigned a value by
$o.output = value.
If an output is synchronous, it must be assigned a value on each processing round. Leaving a synchronous output empty will cause a run-time error. On the other hand, asynchronous outputs do not need to be assigned values.
A tool that calculates has two numeric input parameters:
b and a single output parameter
sum, which is the sum of the
$o.sum = $i.a + $i.b
A tool that strips the first three characters of an input string:
$o.string = $i.string.substring(3)
A tool that multiplies two input matrices (
$o.c = $i.a.times($i.b)
stateEnabled parameter is
true, the script can also use
special state variables that retain their values between
invokations. They can be accessed in the script code through an
$s. For example, storing to the state variable
foo can be done by
$s.foo = 'bar'. Next time the script is run,
$s.foo will have ‘bar’.