Sample Hello Program In UIPath And Use Of Variables In It

Here, we are going to see how we can build a simple Hello World program in an RPA automation tool called UIPath. There are many RPA tools available in the market but we choose UIPath due to its free of cost accessibility. 

For detailed information about RPA and UIPath installation, use the following link of our fellow author's blog where he did a lot of hard work to explain the concept clearly and very fluently.

 

Now, let us move forward for a simple hello program. 

Step 1

Create a new project and create a sequence from the "Activity" tab by dragging it to the main tab. 

Sample Hello Program UIPath And Use Of Variables 

Step 2

Now, drag a dialog activity into the sequence activity.
 
Sample Hello Program UIPath And Use Of Variables 

Step 3

Type a welcome message into the message box either by typing through a keyboard or by setting the text of message box into the Properties tab on the right side of the screen.
 
Sample Hello Program UIPath And Use Of Variables
Step 4
 
Now, hit "Run" on the standard menu tab.
 
Sample Hello Program UIPath And Use Of Variables 

Output 

Sample Hello Program UIPath And Use Of Variables 

So, here is our first simple tutorial. It was very short but we are coming with more broader and interesting logical problems which can be solved using UIPath.

Now, let's see how we can use variables in an automation activity inside the UIPath. If you have formal knowledge of variables in any kind of programming language, it will be easy to understand this, although I will explain it more deeply.

Variable is a special user-defined name which can accept different values depending on that variable type. Its value can be static or dynamic as per the logical state working on it.

New Variable

It is important to have an activity in the main designer panel to create a variable. Right-click on the Activity Properties tab and click on "Create Variable" or press ctrl+k.

Sample Hello Program UIPath And Use Of Variables
 
After pressing ctrl+k, a floating popup will appear, having a label "set Name:". Here, enter a unique name and click on the "Variables" tab at the bottom side.
 
Sample Hello Program UIPath And Use Of Variables 

There are four kinds of editable settings.

  1. Name: Name of the message.
  2. Type: It defines the type of the value this variable can hold. We will discuss it later in detail.
  3. Scope: It defines the activity on which a variable can be accessed. It can be accessed on activity and all its sub-activities.
  4. Default: It sets the default value of a variable if no value is given to the variable.

Variable Type

There are 5 default variables present in the "Variable Type" dropdown.

  • Boolean
  • Int 32
  • String
  • Object
  • Array of [T]

Sample Hello Program UIPath And Use Of Variables 

There is a browse option by which you can browse for other .NET types. Here, you can find many .NET types and use them. For example - ListItem.
 
Sample Hello Program UIPath And Use Of Variables 

If there is anything wrong with the variable creation, then an alert sign will appear on the top right side of the Activity header.

Sample Hello Program UIPath And Use Of Variables 

Now, we will practice with two simple examples using variables.

Example - Welcome Message using variables.

First, create a sequence using the Activity tab. And then, drag a dialog bot activity into it.

Sample Hello Program UIPath And Use Of Variables 

Click on the message box's Property tab and right-click. Then, press "Create Variable".

Sample Hello Program UIPath And Use Of Variables 

Type the variable name and set the type to String and also set the default value.

Sample Hello Program UIPath And Use Of Variables 

Now, click the run icon.

Sample Hello Program UIPath And Use Of Variables 

And here comes the same result using a variable.

Sample Hello Program UIPath And Use Of Variables 

The next article will tell us "How to use variables and Arguments in UIPath". Also, let me know if there is anything I can do to improve my articles. 

Thanks and Happy Coding!!!


Similar Articles