Switch (choosing from multiple options)
🔗 Original page — Source of this material
Description
The Switch operator is an extended version of ❗→ IF (the "If ... then ..." condition) .
While the IF operator has only two outcomes - True or False (green or red branches), Switch allows you to select from multiple options. If none of the options match, the block will exit through the "Default" branch.
How do I add this action to a project?
Via the context menu Add action → Logic → Switch

Or use ❗→ smart search.
What is it used for?
- Selecting an option from a list
- Checking for a specific occurrence (match)
How do you use this action?

Variable
Here you need to specify the variable you want to check
Starting from version 7.4.0.0, you can create a new variable directly from this field (before that, you could only select an existing one).
List of conditions
Here you need to set the exit conditions. The value from the variable will be compared with each of the conditions, and if a match is found, it will follow the corresponding branch.
You can use not only hardcoded text as a condition, but also ❗→ variables:

Default
If there aren't any matches, the action will proceed through the Default branch.
If the Default branch is not connected to any actions and execution hits it, the action will finish with an error.
Example

Example usage
Let's imagine a situation where the variable switch_test has some value.
Next, we'll create ❗→ Notification (Notification/Log entry) actions for each option.
Video example
📹 There was a video here
For those who want to work with C# code
You can implement similar functionality using C# ❗→ C# code (.NET C# code)
Example code for the scenario above
string switch_var = project.Variables["switch_test"].Value;
switch(switch_var){
case "A":
project.SendInfoToLog("The variable contains the letter A", true);
break;
case "B":
project.SendInfoToLog("The variable contains the letter B", true);
break;
case "C":
project.SendInfoToLog("The variable contains the letter C", true);
break;
case "D":
project.SendInfoToLog("The variable contains the letter B", true);
break;
case "E":
project.SendInfoToLog("The variable contains the letter E", true);
break;
default:
project.SendInfoToLog("No suitable match found, variable value: " + project.Variables["switch_test"].Value, true);
break;
}