Workspace 7.1.0

Basic Usage

A select input operation allows you to choose precisely one item from a list of inputs and have only that input brought up to date when the operation executes. The operation selects one input to pass through to the output. This can be used to implement the equivalent of a C++ switch or if-then-else statement.

Example 1: How to implement if-then-else

Note that when used in this way, the first item in the input array corresponds to the false condition, not true. This is because the Index input is simply an integer and boolean false corresponds to 0 and boolean true corresponds to 1. In Example 1, if the condition is false, only the first of the two indexed inputs is brought up to date. The branch containing the operation with the label "Executed for TRUE condition only" is not updated in this case. The reverse occurs if the condition is true rather than false.

A select input operation can be configured to act on any specific data type the workspace supports. Simply right-click on the operation and choose "Change data type". This will change the data type of both the Indexed inputs array and the Selected data output. If you just want to make the SelectInput operation select a branch to execute but not pass through any data, simply choose Dependency as the data type and connect up the dependency output of the branch operations to it, as shown in Example 2.

Example 2: How to implement if-then-else without passing data
See also
Polymorphic Operations, TryInputs