История страницы
...
Throw exception Version 2 (Java)
Группа действий: Базовые действия
Описание
Данное действие предназначено для принудительного завершения работы робота, в связи с тем, что алгоритм на этом шаге продолжаться не должен.
Иконка действия
Параметры действия
Входные параметры
- Поле " Сообщение " - Текст, который будет выведен в лог-файл сообщения.
Настройки
...
Текст, который будет выведен в лог-файл сообщения.
Если параметр не заполнен будет выведено: "Неизвестная ошибка".
...
Action group: Base actions
...
Description
This action is intended to force the robot to terminate, since the algorithm should not continue at this step.
Action icon
Settings of parameters
Property | Description | Type | Filling example | Mandatory field |
Parameters | ||||
Message | Message text to be output to the log file | Robin.String | No |
Special conditions of use
None.
Example of use
Task
It is necessary to get the user's answer to the question about program termination.
If the answer suggests that the work should be terminated, print a message to the log and terminate the work.
Solution
- Add a "Question dialog" action.
- Add an "If" action.
- Add an "Throw exception" action.
Implementation
- Open the "Dialogs" action group.
- Move the "Question dialog" action to the Studio workspace.
- Set the action parameters:
In the "Question dialog" parameter, specify the text: "Stop program operation?"
Open the "Base actions" action group.
Place an "If" action in the Studio workspace (see the description of the "If (Base actions)" action).
- Set the action parameters:
Set the result of the "Question dialog" action in the condition.
Place the "Throw exception" action on the "Yes" branch.
In the "Message" parameter of the "Throw exception" action specify the text: "The user requested to stop the program".
Launch the robot using the "Start" button in the top panel.
Answer "Yes" to the question in the dialog box.
Result
The program was terminated and the message "User requested to stop the program" was displayed in the log.
Особые условия использования
Отсутствуют.
Пример использования
Задача
Необходимо получить ответ пользователя на вопрос о завершении программы.
Если ответ предполагает, что работу необходимо прекратить, вывести в лог сообщение и завершить работу.
Решение
Добавить действие "Вопрос".
Добавить действие "Если".
Добавить действие "Вывести ошибку".
Реализация
...
Настройка действия:
...
Настройка действия:
...
Задать в условие результат действия "Вопрос".
...
Поместить на ветку "Да" действие "Вывести ошибку".
...
Ответить "Да" на вопрос в диалоговом окне.
Результат
Работа программы была завершена, в лог выведено сообщение "Пользователь запросил остановку программы".