Assign value Version 7 (Java)

Action group: Base actions


Description

Assigns the specified value to the result of the action

Action icon

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
Input valueValue that will be to assigned to the «Result» fieldRobin.Object
Yes
Results
ResultOutput that is given in the input field («Input value»)Robin.Object

Special conditions of use

With this action, you can assign a value to a variable at runtime. For example, resetting a counter.

Example of use 

Task

There is a variable "Variable1" with the type "Number" containing the value "0". There is also a loop that can work 10 iterations. It is necessary to terminate the loop when the value of the variable is greater than or equal to 3.

Solution

  1. Add a "For" loop.

  2. Add "Assign value" action.

Implementation

  1. Create a variable "Variable1" with the type "Number", which will contain the value "0".



  2. Open the "Base actions" action group.

  3. Place the Loop "For" action in the Studio workspace and set its parameters (see Loop For Base actions).

    1. Parameter "From". Set the initial value of the counter.

    2. Set the "To" parameter. Set the final value of the counter.

    3. Parameter "Increment". Set the number of increments of the cycle step.



  4. Place in the Studio workspace, inside the Loop "For", the "Assign value" action and set its parameters.

    1. Parameter "Input value". Set the value that will be assigned to the "Result". In this case we select the state (value) of the counter Loop  "For".

    2. Parameter "Result". Set the variable to which the specified value will be assigned. In this case - "Variable1".



  5. Place in the Studio workspace, inside the Loop "For", the "Greater than or equal to" action and set its parameters (see the ">=" Больше или равно).

    1. Parameter "First operand". Set the value of the first operand. In this case it is the value of the variable "Variable1".

    2. Parameter "Second operand". Set the value of the second operand. In this case "3".



  6. Place in the studio workspace, inside the Loop "For", the "If" action and customize it (Look If (Base actions).

    1. Parameter "Condition". Set a boolean expression, the result of which is a condition for passing through the "True" and "False" branches. In this case, the condition is the result of the "Greater than or equal to" action.



  7. Add the "Break the loop" action to the "Truth" branch of the "If" action. (see Break the loop Base actions).

  8. Launch the robot using the "Start" button in the top panel. The final scheme of the robot will look as follows:

Result

The robot completed successfully.


The loop stopped as soon as the value of variable "Variable1" became greater than or equal to 3.

  • Нет меток