Variable Expressions (legacy)

This node provides the possibility to append an arbitrary number of flow variables or modify existing variables using expressions. For each variable that shall be appended or modified a separate expression is defined. These expressions can be simply created using predefined functions similar to the Math Formula and String Manipulation Nodes). Nevertheless there is no restriction on the number of lines an expression has and the number of functions it uses. This allows users to create their own complex expressions.
Additionally, intermediate results of functions or calculations can be stored within an expression by assigning them to variables (using '='). This allows that these results can be reused in different parts of the expression after they have been assigned (see Examples). Note: the names of these variables must be different to all of the predefined function identifiers. Otherwise an error will occur.
To change an expression of an output variable it has to be selected in the list of expressions. By selecting an expression the Expression Editor shows up and the user can modify the expression in the provided text area.
Available flow variables can be accessed via the provided method variable("varName"). For each expression the last computed instruction will be returned.

The syntax and grammar of the expressions are based on the Javascript Languange .

Examples:

  • 5*7+3

    will append a variable with the value 38.

  • v = variable("knime.workspace")
    substr(v, lastIndexOfChar(v,"/"), length(v))

    will create a variable containing the folder name of the KNIME workspace folder.

  • "a1"
    "a2"

    will create a variable with the value "a2", whereas

    a1 = "a1"
    a2 = "a2"
    a1

    will create a variable with the value "a1".

Options

General

+
Adds a new output variable.
-
Removes the selected output variable.

Expression Table

Expression
Shows the currently defined expression for the specified output variable.
Type
Shows the defined type that shall be returned by the script. The resulting variable will have this type in the output table.
Replace Variable
If checked the defined output variable will be replaced. If unchecked the output variable will be appended.
Output Variable
The name of the output variable.

Expression Editor

variable
This opens a list containing all available flow variables. The selected flow variable can be inserted by hitting ENTER or by double clicking it. This menu can be also accessed via the shortcut 'ALT + v' (Windows & Linux) or via 'CTRL + OPTION + v' (Mac) and closed with 'ESC'.
function
This opens a list containing all available predefined functions together with their description. The selected function can be inserted by hitting ENTER or by double clicking it. This menu can be also accessed via the shortcut 'ALT + f' (Windows & Linux) or via 'CTRL + OPTION + f' (Mac) and closed with 'ESC'.
Evaluate
By clicking on this button the current expression will be evaluated and the result will be shown.

Input Ports

Icon
Input variables (optional).

Output Ports

Icon
Output variables.

Views

This node has no views

Workflows

Links

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.