Select index
Description
Returns one of N option values based on a zero-based index. Pure function — only the option the index picks is evaluated; the others are never run, so an option may safely read data that is only valid when it is the one selected. The optional Default pin (`default`) is returned instead when the index is out of range; it counts as set when it is wired or has a typed-in value, and is evaluated only when it is used. Fails the pipeline if the index is out of range and Default is not set. In graph JSON, the option pins are configured in the node config: `options` is a JSON array string such as [{"id":"a"},{"id":"b"}], and each entry gives a generic input pin named `option-<id>`, picked by its position in the array.
When to use
Use Select index when you have a small fixed set of candidate values and want to pick one by numeric index — for example, indexing into an enum-like list of strings or constants. Only the option the index picks is evaluated — the chain behind an unselected pin is never pulled — so an option may safely read data that is only valid when it is the one selected, and an expensive computation on an option costs nothing on the runs that do not choose it. An index outside the options fails the pipeline unless the Default pin is set, in which case Default is returned. To pick by matching a value instead of by position, use Select. For runtime branching of execution (not just values), use Branch or Switch instead.
Pins
Input pins
| Pin | Type | Default | Notes |
|---|---|---|---|
| Index | integer | 0 | Zero-based position picking which option pin to return. |
| Default | generic | — | Returned instead of an option when the index is out of range. It counts as set when it is wired or has a typed-in value, and is only evaluated when it is used. Leave it empty and an out-of-range index fails the pipeline. It takes the same type as the option pins. |
Output pins
| Pin | Type | Notes |
|---|---|---|
| Result | generic | The value of the option pin at the given index, or Default when the index is out of range and Default is set. |
Example
Translate a weekday number (0–6) into a string label. Configure the Select index node with seven string option pins (“Sun” through “Sat”), then wire the day-of-week index into the Index input. Type “?” into Default to get a label even for an unexpected index. The Result output carries the matching label and can be wired into the Message input of Log message.