While Version 12 (Java)

Action group: Base actions


Description

This action is intended to create an action loop that runs as long as the result of the condition is "True". To add a condition, you can use the expression construction tool 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" block.

Action icon

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
ConditionConditionRobin.BooleantrueYes

Special conditions of use

Since this boolean expression is evaluated before each loop execution, the while loop is executed zero or more times.

How to work with the "While" cycle

  1. Select the "While" action from the "Base actions" action group and move it to the script.



  2. Fill the loop body (the block inside the loop where the algorithm for the robot's operation is written) with the necessary actions;
    Example of filling:


  3. Set the parameters of the action:

    1. Condition (the criterion that will be used to decide whether to continue or terminate the cycle).
      Example of filling:  

      If the condition is filled in using the expression construction tool, it will be displayed in the Condition section inside the loop.

      Expression tool:


      If the checkbox is filled in, the loop condition is True. If the checkbox is not filled in and no other condition is specified, the loop condition is considered to be False.
      An example of a loop with a condition filled in using the Expression tool:

 

Example of use  

The case study "First entry". Cycle "While" 

Task

The excel file contains the date and temperature for that date. You need to find the first day in the list when the temperature became negative.

Solution

  1. Create variables "Counter" and "Meaning" variable type - number. 


  2. Move the "Open" and "Column data" actions (Excel group), the "While" action (Base actions group), the "Save" and "Close" actions (Excel group) to the workspace. 



  3. Set the action parameters:
    1. Action "Open": in the line "Path to file" specify the path to the excel-file with which the work will be performed.



    2. "Column data" action. Specify the context and name of the column with temperature data.



    3. "While" action. Use the expression construction tool to write the condition "Variable Value is greater than 0". 



    4. Action "Save". In the "Context" line specify an instance of the opened Excel file.



    5. Action "Close". In the "Context" line specify an instance of the opened Excel file. 


  4. In the loop body, add the "Get value by index" action (the "Collections" action group) and the "Addition" action (the "Operators" action group).


  5. Set the parameters for these actions:
    1. "Get value by index" action.
      In the Collection line specify the result of the "Get data from column" action.
      In the line "Index" specify the variable "Counter".
      In the "Result" parameter write the variable "Value".



    2. Action "Addition".
      The first summand is the "Counter" variable.
      The second summand is 1.
      The result is the "Counter" variable.



  6. Add a "Message" action.
    1. Message text - variable "Value".
    2. Window title - "First negative number from file".

Result

Robot completed successfully.

The algorithm looped through the values of the collection and will stop as soon as it encounters the first negative number. The robot displays a dialog box with the result.


 


  • Нет меток