Subscribe

UiPath Studio

The UiPath Studio Guide

Array Variables

The array variable is a type of variable which enables you to store multiple values of the same type.

UiPath Studio supports as many types of arrays as it does types of variables. This means that you can create an array of numbers, one of strings, one of boolean values and so on.

Example of Using an Array Variable

To exemplify how you can work with array variables, we are going to create an automation that asks the user for his first and last name and age, stores the information in an array and then writes it in a .txt file.

  1. Create a new sequence.
  2. Create three string variables, FirstName, LastName and Age, in which to store the information gathered from the user.
  3. Create an array of strings variable called NameAge.
1160
  1. Add an Input Dialog activity to the Designer panel.
  2. In the Properties panel, fill in the Label and Title fields to ask for the user’s first name.
  3. In the Result field, type the FirstName variable. This variable stores the first name of the user.
  4. Add another Input Dialog activity under the previous one.
  5. In the Properties panel, fill in the Label and Title fields to ask for the user’s last name.
  6. In the Result field, type the LastName variable. This variable is going to store the last name of the user.
  7. Add another Input Dialog activity under the previous one.
  8. In the Properties panel, fill in the Label and Title fields to ask for the user’s age.
  9. In the Result field, type the Age variable. This variable is going to store the age of the user.

📘

Note:

We use a string variable and not an integer to store the age, so that we do not have to convert it later on, when we add it to the string array variable.

  1. Add an Assign activity under the last Input Dialog.
  2. In the Properties panel, in the To field, type the NameAge variable.
  3. In the Value field, type {FirstName,LastName,Age}. This Assign activity enables you to store all the values from the initial string variables in the NameAge one.
  4. Add a Write Text File activity under the Assign one.
  5. In the Properties panel, in the FileName field, type the path of the file you want to write to between quotation marks, such as "%HOMEPATH%\Desktop\array_variable.txt".

📘

Note:

If the file does not exist at the provided path, it is created.

  1. In the Text field, type NameAge(0) + " " + NameAge(1) + " " +NameAge(2) + " ".

📘

Note:

By adding the index number of the array items you can access their values and write them, in this example, to a text file.

The final project should look as in the following screenshot.

365
  1. Press Ctrl + F5 to run the project.
  2. Navigate to the file provided at step 17 and double-click it. A Notepad window is displayed with the information you added at step 20.
331

Download example

Updated 3 years ago


Array Variables


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.