Break the loop Version 7 (Java)

Action group: Base actions


Description

This action is intended to interrupt the current iteration of the loop/branching and exit the loop/branching. Actions in the loop set after the " Break the loop" action will not be completed.

Action icon

Settings

None.

Special conditions of use

Must be used inside the loop, otherwise the System will display the warning "The " Break the loop action is outside the loop".

Example of use

Task

There are variables of type "Collection" and "Number" containing the value "(1988, 8, 2, 4)" and "2" respectively.

The loop must be terminated until the value of the numeric variable is equal to the value of one of the elements of the collection (the value "2").

Solution

  1. Add a "Foreach" loop.
  2. Add an "If" condition. Add a loop interrupt and a message in the log to the "True" branch.
  3. Message in the log.

Implementation

  1. Create a variable "Numeric_variable2" with type "Number", which will contain the value "2".
  2. Create a variable "Collection" with elements"(1988, 8, 2, 4)" to be traversed in the loop.


  3. Open the "Base actions" action group. Place the loop "Foreach" action in the Studio workspace. In the loop "Foreach" action, select the previously created variable of the "Collection" type in the "Collection" parameter.



  4. Open the "Operators" action group. Place inside the loop "For Each"" action the "Equal to" action. In the parameters of the "Equal to" action, specify the parameters "First operand" and "Second operand". In the "First operand" parameter, select the loop iteration value "For each.Object". In the "Second operand" parameter, select the previously created variable "Numeric_variable2".

     (see the description of the action "For each").


  5. Place the "If" action in the studio workspace (see the description of the action "If (Base actions)"). 
    1. Place the "Message in log" action in the "If" action workspace of the "True" branch (see the description of the action "Message in log Base actions"). 
    2. Place the "Break the loop" action in the "If" action workspace of the "True" branch.
  6. Place the "Message in log" action in the Studio workspace (see the description of the action "Message in log Base actions").
     
  7. Launch the robot using the "Start" button in the top panel.

Result

The algorithm went through the loop and was broken after setting the variable to "2".

 

  • Нет меток