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
Property | Description | Type | Filling example | Mandatory field |
Parameters | ||||
Input value | Value that will be to assigned to the «Result» field | Robin.Object | Yes | |
Results | ||||
Result | Output 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
Add a "For" loop.
Add "Assign value" action.
Implementation
Create a variable "Variable1" with the type "Number", which will contain the value "0".
Open the "Base actions" action group.
Place the Loop "For" action in the Studio workspace and set its parameters (see For (Base actions)).
Parameter "From". Set the initial value of the counter.
Set the "To" parameter. Set the final value of the counter.
Parameter "Increment". Set the number of increments of the cycle step.
Place in the Studio workspace, inside the Loop "For", the "Assign value" action and set its parameters.
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".
Parameter "Result". Set the variable to which the specified value will be assigned. In this case - "Variable1".
Place in the Studio workspace, inside the Loop "For", the "Greater than or equal to" action and set its parameters (see the ">=" Больше или равно).
Parameter "First operand". Set the value of the first operand. In this case it is the value of the variable "Variable1".
Parameter "Second operand". Set the value of the second operand. In this case "3".
Place in the studio workspace, inside the Loop "For", the "If" action and customize it (Look If (Base actions).
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.
Add the "Break the loop" action to the "Truth" branch of the "If" action. (see Break the loop (Base actions)).
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.