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

Ключ

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

...

Throw exception Version 2 (Java)

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

Описание

Данное действие предназначено для принудительного завершения работы робота, в связи с тем, что алгоритм на этом шаге продолжаться не должен.

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

Image Removed

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

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

  1. Поле " Сообщение " - Текст, который будет выведен в лог-файл сообщения

Настройки

...

Текст, который будет выведен в лог-файл сообщения.

Если параметр не заполнен будет выведено: "Неизвестная ошибка".

...

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

Image Added

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
MessageMessage text to be output to the log fileRobin.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

  1. Add a "Question dialog" action.
  2. Add an "If" action.
  3. Add an "Throw exception" action.

Implementation

  1. Open the "Dialogs" action group.
  2. Move the "Question dialog" action to the Studio workspace.
  3. Set the action parameters:
    1. In the "Question dialog" parameter, specify the text: "Stop program operation?" 

  4. Open the "Base actions" action group.

  5. Place an "If" action in the Studio workspace (see the description of the "If (Base actions)" action).

  6. Set the action parameters:
    1. Set the result of the "Question dialog" action in the condition.

    2. Place the "Throw exception" action on the "Yes" branch.

    3. In the "Message" parameter of the "Throw exception" action specify the text: "The user requested to stop the program".


      Image Added

      Image Added


  7. Launch the robot using the "Start" button in the top panel.

  8. 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.

Image Added

 

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

Отсутствуют.

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

Задача

Необходимо получить ответ пользователя на вопрос о завершении программы.

Если ответ предполагает, что работу необходимо прекратить, вывести в лог сообщение и завершить работу. 

Решение

  1. Добавить действие "Вопрос".

  2. Добавить действие "Если".

  3. Добавить действие "Вывести ошибку".

Реализация

...

Настройка действия:

...

Настройка действия:

...

Задать в условие результат действия "Вопрос". 

...

Поместить на ветку "Да" действие "Вывести ошибку".

...

Ответить "Да" на вопрос в диалоговом окне.

Результат

Работа программы была завершена, в лог выведено сообщение "Пользователь запросил остановку программы".

Image Removed