Switch

The Switch Component is used to perform actions based on multiple conditions.

Screenshot

Ports

The Switch component exposes Control In and Control Out ports by default.

Port Description
Control In Must be connected to the Control Out port of one or more components.
Control Out Control Out ports on the Switch Component are dynamic and must be connected to the Control In port of any other component. The Switch component exposes the following two types of Control Out ports:
Case: Cases can be added by selecting the Screenshot icon on the Switch Component title bar. Execution flow is passed to a specific Case Control Out port when the data provided from the corresponding Data In port matches the data provided to the Comparison Data In port.
Else: Execution flow is passed to the Else Control Out port when data provided to the Comparison Data In port does not match with data provided to any Case Data In ports.
Data In Can be connected to the Data Out port of another component from where data is to be collected. The Switch Component exposes the Following Data In ports:
Comparison Data In: Data (String/Int32/Object) provided to this port will be compared with the data provided to each Case Data Inports.
Case Data In: Execution flow is passed to a specific Case Control Out port when the data provided via the corresponding Data In port matches the Data provided to the Comparison Data In port.

Properties

To edit the properties of the Switch component, in the lower-right pane, change the required property. This is necessary to select the action to be performed with the switch component.

User can edit the following properties-

Property Description
Search Searches for the respective property.
Delay After Execution Specifies the wait time (in seconds) after the action is executed.
Delay Before Execution Specifies the wait time (in seconds) before the action is executed.
Name Specifies the name for the Switch component.
Set the name to match the application field which the user is interacting with.

Example

Let us consider an example of switch case where mutlple colors must match and send controls forward to components based on the matched colors.

Screenshot

To use the Switch component:

  1. In the Toolbox, expand Conditions.

  2. Drag the Switch component and drop it on the Design surface.

  3. On the Switch component, to add switch cases, in the title bar, click .Screenshot

    Note

    Click, Screenshot to delete the switch cases.

  4. To enter a case, in the Switch component, double-click within the Option box. The PORT PROPERTIES dialog box is displayed.

  5. Under Read Data From, select Static.

    Note

    Under Read Data From, user can also select Connection or Variable.
    To learn more about the Connection or Variable data source override options, refer the Override section.

  6. In the Static Value box, enter the switch case needed to be added. For this example, type Green.

  7. Click OK.
    The Design surface displays the process flow.

  8. Similarly, enter a different switch case. In this example, type more three colors; Blue, Red, and White.

    To add an input value to meet the swith case condition, add a Variable component.

  9. To add the Variable component:

    • In the Toolbox, expand General.

    • Drag the Variable component and drop it on the Design surface.

    • Double-click the Variable component and enter the input value.

    The user must add a Message Box Show component to display the results of the various Switch Case conditions provided.

  10. To add the Message Box Show component:

    • In the Toolbox, expand General.

    • Expand the MessageBox component, drag Show component and drop it on the Design surface.

    • In the Show component enter a message to display the result when a case is satisfied. For this example, write the case number for every case in the switch component.

    • Add a messagebox for every case and also for the ELSE case. In the messagebox for the ELSE case, enter a message which displays the result when no case not satisfied.

  11. Connect:

    • The Control Out port of the Start component to the Control In port of the Variable component.

    • The Control Out port of the Variable component to the Control In port of the Switch component.

    • The Data Out port of the Variable component to the Data In port of the Switch component.

    • The Control Out port of the Switch component of every case to the Control In port of its corresponding MessageBox component.

    • Connect the Else Control Out port of the Switch component to its corresponding MessageBox component.

  12. In the toolbar, click Run.

    If the input value in the variable component satisfies any of the cases in the Switch component the message corresponding to switch case will be displayed.

    Screenshot

    If the input value in the variable component does not satisfy any of the cases in the Switch component the message corresponding to ELSE will be displayed.

    Screenshot