9.1) Array Variables Type

Most of the examples shown up to this point were simple variables, that can store a single value at a time. It’s time to look into the collection variables, starting with array variables.

What is it?
The array variable is a type of variable that enables storing multiple values of the same data type. Think of it as a group of elements with a size that is defined at creation, and each item can be identified by its index.

In UiPath Studio, you can create arrays of numbers, of strings, of Boolean values and so on.


What are some business scenarios in which I will use arrays?
  • When we want to save the names of the months to a variable
  • When a fixed collection of bank accounts has to be stored and used in the payment process
  • When all the invoices paid in the previous month have to be processed
  • When the names of the employees in a certain unit have to be verified in a database
            

Arrays are useful in lot of real time scenarios where we need to store multiple values of the same type. For ex: We need to store 100 different strings that will need to be added to different emails. It's easier to use specific strings from an array for the designated emails. 


Creating an Array:
Step1 : Sequence-> Add activity->create variable(cntrl+K)-> Go to variables panel and change the type to Array of [T] data type. And we initialize Default value to new String(){}
Step2: Add values to array. {"John", "Doe"}
                                
We can add Annotation as below if we want to 
                                  

Step3: We can output value of Array using log message using stringArray(0) etc
                                        
Output will be displayed as John Dave.

Step4: How to modify the element in the Array. Say John to Jane

Add an activity and say stringArray(0)="Jane"
Then add another Log message and try to display stringArray() in entire with elements separated with space. This can be done using string.Join(" ", stringArray) We see the first element will be changed


In the output pane we see values before changing and after changing in right

No comments:

Post a Comment

Sequence and Flowcharts

  UiPath recommends that the first part of the Robot should start with Flowchart or Sequence. We can nest Sequence inside Sequence, Flowchar...