Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
iconfalse
titleThis page has been translated automatically

We want to provide you with the latest help content in your language as soon as possible. This page has been translated automatically and may contain grammatical errors or inaccuracies. We want this content to be useful to you. Please let us know at the bottom of this page if this information was helpful.

View the original article in Russian: Выбор вариантов (Оператор "Switch")

Описание

Description

The Switch statement is an extended version Condition Условие "If Если ... then то ..." (Statement Оператор "IF") ...

If the “IF” statement has only two outcomes - True or False (green or red branches), then Switch has the ability to choose several options. In the absence of the desired option, the cube will be released on the “Default” branch.

How

...

to add an action to a project?

Via the context menu Add ActionLogicSwitch

...

  • Choosing an option from the list

  • Checking for a specific occurrence (match)

How

...

to use the action?

...

As a condition for the exit, you can use not only hard-coded text, as in the examples above (A, B, C, D, E), but also other variables:

...

Variable

Here you need to specify the variable that we will check

...

Expand
titleFor those who want to work with C # code

You can implement similar functionality via C # C # code (C sharp code .net)

Sample code for the option above

Code Block
languagec#
string switch_var = project.Variables["switch_test"].Value;
switch(switch_var){
case "A": 
project.SendInfoToLog("В переменной заключена буква A", true);
break;
case "B": 
project.SendInfoToLog("В переменной заключена буква B", true);
break;
case "C": 
project.SendInfoToLog("В переменной заключена буква C", true);
break;
case "D": 
project.SendInfoToLog("В переменной заключена буква B", true);
break;
case "E": 
project.SendInfoToLog("В переменной заключена буква E", true);
break;
default:
project.SendInfoToLog("Не обнаружено нужное соответствие, значение переменной: " + project.Variables["switch_test"].Value, true);
break;
}

...

Working with variables

Variable window

Condition "If Работа с переменными

Окно переменных

Условие "Если ... then то ..." (Statement Оператор "IF")

Notification (Notification / Logging)