Continue the loop Version 7 (Java)

Action group: Base actions


Description

This action is intended to interrupt the current iteration of the loop and start the next iteration. Actions in the loop set after the “Continue 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 message "Continue the loop action is outside the loop".

Example of use

Task

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

Terminate the loop until the value of the numeric variable is equal to the value "2".

If the array element is not equal to the value "2", then the current iteration must be interrupted and the next iteration must begin.

Solution

  1. Add "Foreach" loop.
  2. Add condition "If". Add a loop break and a blog message to the "True" branch.

  3. Message to log.

Implementation

  1. Create a variable "Numeric_variable 2" with the type "Number", which will contain the value "2".



  2. Create a "Collection" variable with elements"(1988, 8, 2, 4)", the passage through which will be carried out in a cycle.




  3. Open "Base actions" action group.
    1. Move the "Foreach" loop action to the workspace.
    2. In the "Foreach" loop action in the "Collection" parameter select already existing "Collection" type variable.



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



  5. Move the "If" action to the workspace.
    1. Place the "Message in log" action in the workspace of the "If" action of the "True" branch. Place the "Break the loop" action in the workspace of the "If" action of the "True" branch.


    2. Place the "Message in log" action in the workspace of the "If" action of the "False". Place the "Continue the loop" action in the workspace of the "If" action of the "False" branch.


  6. Move the "Message in log" action to the workspace.

  7. Click "Start" in the top panel to start the robot. The final scheme will look like this:

Result

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

 

  • Нет меток