Variables
Store and retrieve values within a pattern execution using variables.
What are variables?
Variables let you store values that persist across nodes within a single execution. They act as named containers — you set a value at one point in your pattern and retrieve it later at another point.
When to use variables
Variables are useful when you need to:
- Accumulate results across a loop (e.g., building a list of processed items)
- Store intermediate values that multiple downstream branches need
- Track state through complex flow control (e.g., counting iterations or flagging conditions)
If a value flows directly from one node to the next, pass it through wires instead. Variables are for cases where the data path is not a straight line.
Creating a variable
You define variables in the Inspector Panel on the left side of the editor. Each variable has:
- Name — a unique identifier used by Get Variable and Set Variable nodes
- Type — the pin type of the value (string, integer, boolean, object, etc.)
- Default value — the initial value at the start of each execution
Using variables in your pattern
Two nodes work with variables:
Set Variable
Sets a variable to a new value. This node has an input data pin that accepts the value to store. Place it in your execution flow at the point where you want to update the variable.
Get Variable
Reads the current value of a variable. This is a pure node — it has no execution pins and evaluates inline whenever a downstream node needs the value.
Variable scope
Variables are local to a single execution. Each execution starts with the default values and any changes made by Set Variable are visible only within that execution.
- Variables are not shared between concurrent executions of the same pattern
- Variables are not shared between different patterns (use pattern calls with input/output pins instead)
- Variable values are not persisted after the execution completes
Variable types
Variables support the same types as data pins:
| Type | Default value example |
|---|---|
| String | "" |
| Integer | 0 |
| Float | 0.0 |
| Boolean | false |
| Object | {} |
| Array | [] |
| DateTime | Current timestamp |
Variables vs wires
| Wires | Variables | |
|---|---|---|
| Best for | Direct node-to-node data flow | Storing state across branches or loops |
| Visibility | Explicit in the graph | Defined in Inspector Panel |
| Scope | Between two connected pins | Entire execution |
| When to use | Value goes from A to B | Value is set in one place, read in another |
In general, prefer wires for simple data flow. Use variables when the data path is indirect — through loops, branches, or when multiple unconnected nodes need the same value.
Related concepts
- Nodes and pins — Get Variable and Set Variable are part of the node library
- Type system — variable types follow the same rules as pin types
- Executions — variable scope is tied to a single execution