Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

...

While Version 12 (Java)

Группа действий: Базовые действия 

Описание

Данное действие предназначено для создания цикла действий, который выполняется до тех пор, пока результат условия равен "True". Для добавления условия может использоваться инструмент построения выражений в параметре "Условие". Для добавления в тело цикла последовательности действий необходимо переместить их на контур блока "Тело цикла".

Иконка действия

Image Removed

Параметры действия

Входные параметры

  1. Чекбокс "Условие". Условие цикла. Критерий, по которому будет приниматься решение о продолжении или прекращении работы цикла.

Настройки

Action group: Base actions

...

Description

This action is intended to create an action loop that runs as long as the result of the condition is "True". To add a condition, you can use the expression construction tool in the "Condition" parameter. To add a sequence of actions to the loop body, you must move them to the outline of the "Loop body" block.

Action icon

Image Added

Settings of parameters

СвойствоОписаниеТипПример заполненияОбязательность заполнения поляПараметрыУсловиеУсловие
PropertyDescriptionTypeFilling exampleMandatory field
Parameters
ConditionCondition
Robin.Booleantrue
Да

Особые условия использования

Так как это логическое выражение оценивается перед каждым выполнением цикла, цикл "Пока" выполняется ноль или несколько раз.

Порядок работы с циклом «Пока»

...

Пример использования 

Кейс «Первое вхождение». Цикл «Пока» 

Задача

В excel-файле записаны дата и температура за это число. Необходимо найти первый день в списке, когда температура стала отрицательной.

Image Removed

Решение

...

Yes

Special conditions of use

Since this boolean expression is evaluated before each loop execution, the while loop is executed zero or more times.

How to work with the "While" cycle

  1. Select the "While" action from the "Base actions" action group and move it to the script.

    Image Added

  2. Fill the loop body (the block inside the loop where the algorithm for the robot's operation is written) with the necessary actions;
    Example of filling:
    Image Added

  3. Set the parameters of the action:

    1. Condition (the criterion that will be used to decide whether to continue or terminate the cycle).
      Example of filling:  
      Image Added

      If the condition is filled in using the expression construction tool, it will be displayed in the Condition section inside the loop.

      Expression tool:
      Image Added

      If the checkbox is filled in, the loop condition is True. If the checkbox is not filled in and no other condition is specified, the loop condition is considered to be False.
      An example of a loop with a condition filled in using the Expression tool:

      Image Added

 

Example of use  

The case study "First entry". Cycle "While" 

Task

The excel file contains the date and temperature for that date. You need to find the first day in the list when the temperature became negative.

Image Added

Solution

  1. Create variables "Counter" and "Meaning" variable type - number. 
    Image Added

  2. Move the "Open" and "Column data" actions (Excel group), the "While" action (Base actions group), the "Save" and "Close" actions (Excel group) to the workspace. 

    Image Added

  3. Set the action parameters:
    1. Action "Open": in the line "Path to file" specify the path to the excel-file with which the work will be performed.

      Image Added

    2. "Column data" action. Specify the context and name of the column with temperature data.

      Image Added

    3. "While" action. Use the expression construction tool to write the condition "Variable Value is greater than 0". 

      Image Added

    4. Action "Save". In the "Context" line specify an instance of the opened Excel file.

      Image Added

    5. Action "Close". In the "Context" line specify an instance of the opened Excel file. 
      Image Added

  4. In the loop body, add the "Get value by index" action (the "Collections" action group) and the "Addition" action (the "Operators" action group).
    Image Added

  5. Set the parameters for these actions:
    1. "Get value by index" action.
      In the Collection line specify the result of the "Get data from column" action.
      In the line "Index" specify the variable "Counter".
      In the "Result" parameter write the variable "Value".

      Image Added

    2. Action "Addition".
      The first summand is the "Counter" variable.
      The second summand is 1.
      The result is the "Counter" variable.

      Image Added

  6. Add a "Message" action.
    1. Message text - variable "Value".
    2. Window title - "First negative number from file".

      Image Added

Result

Robot completed successfully.

Image Added

The algorithm looped through the values of the collection and will stop as soon as it encounters the first negative number. The robot displays a dialog box with the result.

Image Added


 

...

Результат

Робот отработал успешно.

Image Removed

Алгоритм перебрал значения коллекции в цикле и прекратит работу, как только встретит первое отрицательное число. Робот вывел диалоговое окно с результатом.

Image Removed