Switch Version 5 (Net)
Action group: Base actions
Description
The action selects the execution of a single branching section from a list of options, comparing them to a match expression.
To add a new conditions click on the "
" button in the action.To add a default transition branch, click on the "" button in the action.
Action icon
Settings of parameters
Property | Description | Type | Filling example | Mandatory field |
Parameters | ||||
Condition | The value to be matched against branches“ values to select executing branch | Robin.String | Yes | |
Branch 1 condition | If matches the condition, the corresponding branch will be executed | Robin.String | Yes | |
Branch 2 condition | If matches the condition, the corresponding branch will be executed | Robin.String | Yes |
Special conditions of use
When adding a default transition branch, this branch will be executed if the condition did not match in the other branches.
Example of use
Task
There is a variable with type "String" containing the value "Red".
You need to go to the appropriate branching section and output a message to the log.
Solution
- Add switch.
- Add message to log.
Implementation
Create a variable "String_ Variable 1" with the type "String", which will be an expression and contain the text "Red".
Open the "Base action" action group.
Move the "Switch" action to the workspace.
Triple-click on the "
" button in the action.Action settings:
"Condition" parameter. Select the variable "Branch 1 condition", the value of which will be checked for compliance with the conditions.
"Branch 1 condition" parameter. Select the result of the expression "Blue", which will be compared with the value in the "Conditions" field of the "Switch" action.
"Branch 2 condition" parameter. Select the result of the expression "Red", which will be compared with the value in the "Conditions" field of the "Switch" action.
"Branch 3 condition" parameter. Select the result of the expression "Black", which will be compared with the value in the "Conditions" field of the "Switch" action.
Place the "Message in log" action with the message "Branch no.1", "Branch no.2" and "Branch no.3" corresponding to the branch number (read action description "Message in log").
Click "Start" in the top panel to start the robot.
Result
The algorithm went through branch No. 2 and output the message to the log "Branch No. 2".