> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/function-blocks/blocks-reference/data-logic/signal-operators/multi-port-switch.md).

# Multi Port Switch

This function block routes one of many incoming values to its output based on a reference selector. Use it when you want to pick a single input stream (or value) from a configurable list at runtime.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Switch` Accepts a selector value. This can be:

* a single number (selects the input at that index), or
* a boolean/list of booleans (selects the first input where the value is TRUE).

`Input 0`, `Input 1`, ... Additional generic inputs. The number of available inputs is adjustable via the block controls.

(Each of the above are input sockets on the block.)

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Generic` The output forwards the data coming from the selected input socket.

(This is the output socket on the block.)

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Number of inputs` A dropdown that lets you choose how many input sockets the block exposes (more inputs appear or are removed accordingly).

(Use this control to adapt the block to your scenario — from a few inputs up to the configured maximum.)

## ⚙️ Running mechanism <a href="#how-it-runs" id="how-it-runs"></a>

* The block reads the value provided to `Switch` and determines which input to route.
* If `Switch` is a number, the block routes the input at that numeric index.
* If `Switch` is a boolean list, the block finds the first TRUE entry and routes the corresponding input.
* If the selected input is not connected or empty, the block reports an invalid selection and does not forward a value.

This behavior makes the block suitable for runtime decision-making and conditional routing in visual flows.

## ✨ Features <a href="#features" id="features"></a>

* Dynamic input count: Add or remove inputs from the UI without redesigning the flow.
* Accepts numeric or boolean selectors for flexible control.
* Generic input/output sockets: works with images, numbers, text, lists, or other data types.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. Set the desired number of inputs with `Number of inputs`.
2. Provide values to the corresponding `Input X` sockets.
3. Drive the `Switch` socket with a numeric selector (use `Number Input`) or a boolean/list selector (use `Logic Input` or other logic-producing blocks).
4. Read the routed value from the `Generic` output.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Use `Number Input` to manually choose an input index during testing.
* Use `Logic Input` or logical operators such as `And` / `Or` to generate boolean selectors for the `Switch` socket.
* Combine with `Mux` or `Demux` when converting between grouped/listed data and individual sockets. For example, gather values into a list with `Demux` then use a boolean list to select one with this block.
* Use `Data Memory` to hold a selected value and feed it back as a stable input to the block.
* Place this block before `Show Image` to switch which image source is displayed, or before an analysis block like `Find Object` to test different image inputs quickly.
* In automation flows, combine with `Subsystem Enabled` or `Set - Reset` to switch sources depending on system state.

(hint: recommended companion blocks include `Number Input`, `Logic Input`, `Mux`, `Demux`, `Data Memory`, `Show Image`, and `Find Object`.)

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* If nothing appears on the output, check that the selected input socket is connected and that `Switch` points to the correct index or TRUE entry.
* If selection jumps unexpectedly, verify the source driving `Switch` (it may be changing each cycle). Use `Data Memory` to stabilize the selector if needed.
* If you need more inputs than currently available, increase the count with `Number of inputs` and reconnect your sources.
