Example

In the following example, we shall use the For each activity to go through a collection of even numbers and display each element one at a time. 

Perform the following steps:

  1. Start with a Blank project in UiPath.
  2. Add a Sequence activity to the Designer panel.
  1. Next, add a For each activity within the Sequence and create an integer type array variable, x.
  1. In the default value of the variable, put in ({2,4,6,8,10,12,14,16,18,20}).
  2. Add a Write line activity to the Designer Panel (this activity is used to display the results).
  3. In the Text field of the Write line activity, type item.ToString to display the output:
  1. Now, run the program. You will see that each number of the array is displayed one by one because of the use of the For each activity:

The Control flow also facilitates decision-making mechanisms that can help in taking a decision on a particular activity's step. For example, suppose we are using a loop and we want to display only a desired value, then we can filter out all our desired values by implementing the If activity, and making a decision based on the basis of the If activity's result, that is, true or false. The decision-making process will require some time to break the action after executing the desired element. This is followed by the Break activity, which will play a significant role. If you want to choose an execution from the task, then the activity needs to be switched in order to make such a decision.

The If activity and the Switch activity are the Control flow's decision-making activities.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.150.80