История страницы
...
Do while Version 12 (Java)
Группа действий: Базовые действия
Описание
Данное действие предназначено для создания цикла действий, который выполняется до тех пор, пока результат условия равен "True". Для добавления условия используется инструмент построения выражений в параметре «Условие». Для добавления в тело цикла последовательности действий необходимо переместить их на контур блока "Тело цикла".
...
Action group: Base actions
...
Description
This action creates an action loop that runs as long as the result of the condition is "True". To add a condition, the expression construction tool is used 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" clause.
Action icon
Settings of parameters
Property | Description | Type | Filling example | Mandatory field |
Parameters | ||||
Condition | Condition | Robin.Boolean | true | Yes |
Особые условия использования
Так как это логическое выражение оценивается после каждого выполнения цикла, цикл "Пока" выполняется один или несколько раз.
Порядок работы с «Циклом с постусловием»
Special conditions of use
Since this boolean expression is evaluated after each loop execution, the "While" loop is executed one or more times.
How to work with the "Do while" action
1.Select the "Do While" action from the "Base actions" action group and transfer it to the script1.Выбрать действие"Do While" из группы действий «Базовые действия» и перенести в сценарий.
2. Заполнить тело цикла необходимыми действиями.
Пример заполненияFill the loop body with the necessary actions.
Filling example:
3. Заполнить параметры действия "Условие"
Пример заполнения:
Если условие заполняется посредством инструмента построения выражений, то оно отобразиться в разделе «Условие» внутри цикла.
Пример цикла с постусловием, где условие заполнено с помощью инструмента построения выражений:
Сравнение циклов «While» и цикла с «Do While».
Оба цикла работают до тех пор, пока результат условия равен "True". Однако в цикле "While" проверка действия происходит перед началом выполнения цикла, т.е. цикл может отработать 0 раз и более.
Проверка условия в действии"Do While" происходит после выполнения действий в теле цикла, т.е. цикл отработает минимум один раз.
Пример использования
Set the "Condition" action parameters.
Filling example:
If the condition is filled in using the expression builder tool, it will appear in the "Condition" section inside the loop.
An example of a loop with a postcondition where the condition is filled in using the expression construction tool:
Comparing the "While" and "Do While" loops
Both loops work as long as the result of the condition is "True". However, in the "While" loop, the action is checked before the loop starts executing, i.e. the loop may run 0 times or more.
The condition check in the "Do While" action takes place after the actions in the loop body are executed, i.e. the loop will run at least once.
Example of use
"Search file" case
...
. "Do While".
Задача
В папке есть несколько подпапок, где лежит необходимый нам файл. Нужно просмотреть подпапки и выяснить в какой из них сохранен этот файл.
Решение
1. Создать переменную «Счетчик», тип переменной – число.
2. Создать переменную «Значение», тип переменной – объект.
Task
There are several subfolders in the folder where the file we need is stored. Look through the subfolders and find out in which of them this file is saved.
Solution
1. Create a variable "Counter", variable type - number.
2. Create a variable "Value", variable type - object.
3. Move the "Folder list" (action group "File system"3. На рабочую область перенести действия "Folder list" (группа действий «Файловая система»),"Do While" (группа действий «Базовые действия»)action group "Base actions") actions to the workspace.
4. В тело цикла добавить действия Add actions "Get value by index" (группа действий action group "Collections"), "Convert data" (группа действий action group "Base actions"), "Search file" (группа действий action group "File system") и and "Addition" (группа действий action group "Operators") to the loop body.
Реализация
Implementation
- Create a variable "Counter", variable type - numberСоздать переменную «Счетчик», тип переменной – число.
Создать переменную «Значение», тип переменной – объектCreate a variable "Value", variable type - object.
На рабочую область перенести действия Move the "Folder list" (группа действий «Файловая система»action group "File system"),"Do While" (группа действий «Базовые действия»)action group "Base actions") actions to the workspace.
- Заполнить параметры действия Set the "Folder list" :
- В параметр «Папка» указать путь до папки с подпапками. В параметре «Тип объектов» выбрать из выпадающего списка значение «Только папки».
- In the "Folder" parameter specify the path to the folder with subfolders.
- In the "Objects type" field select "Only folders" value from the dropdown list.
- Set the Заполнить параметры действия "Do While" :action parameters:
- Use the expression construction tool to write the condition "The length of the collection obtained as a result of the "Find file" action is 0" into the condition parameter. To do this, create one more variable "Additional variable", in which the number 0 will be written.
Example - В параметр условие с помощью инструмента построение выражений записать условие «Длина коллекции, полученной в результате действия «Найти файл» равно 0». Для этого создадим еще одну переменную «Доп. переменная», в которой будет записано число 0
Пример:
- В тело цикла добавить действия Add actions "Get value by index" (группа действий action group "Collections"), "Convert data" (группа действий action group "Base actions"), "Search file" (группа действий action group "File system") и and "Addition" (группа действий action group "Operators") to the loop body.
- Use the expression construction tool to write the condition "The length of the collection obtained as a result of the "Find file" action is 0" into the condition parameter. To do this, create one more variable "Additional variable", in which the number 0 will be written.
Set the "Get value by index" action parameter:
- "Collection" parameter -
Заполнить параметры действия «Получить значение по индексу»:
- Параметр «Коллекция» - результат действия "Folder list" action result.
- Параметр «Индекс» - переменная «Счетчик».
- Параметр «Результат» - переменная «Значение».
- Параметр «Источник» - результат действия «Получить значение по индексу». Параметр «Тип» - путь к папке.
- Параметр «Путь к папке» - результат действия «Конвертировать данные». Параметр «Имя файла» - название искомого файла.
- Заполнить параметры действия «Сложение»:
- Первое слагаемое – переменная «Счетчик».
- Второе слагаемое – 1.
- Результат – переменная «Счетчик».
Запустить робота по кнопке "Запуск" в верхней панели.
action parameters:
Заполнить параметры действия «Найти файл»:
Результат
- "Index" parameter - "Counter" variable.
- "Result" parameter - "Value" variable.
- Set the "Convert data" action parameter:
- "Source" parameter - "Get value by index" action result.
- "Data type" parameter - path to file.
- Set the "Find file" action parameters:
- "Folder path" parameter - "Convert data" action result.
- "File name" parameter - name of the needed file.
- Set the "Addition" action parameters:
- The first addendum - "Counter" variable.
- The second addendum - 1.
- Result - "Counter" variable.
- Click "Start" in the top panel to start the robot.
Result
The algorithm will loop until the desired file is found. The path to the folder with this file will be saved to the variable "Value".Алгоритм пройдет по циклу до тех пор, пока не будет найден искомый файл. Путь до папки с этим файлом будет сохранен в переменную «Значение».