An introduction to RPA programming with UiPath Studio

The promise of RPA software is that it can quickly and easily create reusable and repeatable tasks.

Companies such as UIPath, Automation Everywhere and Blue Prism offer “low-code” or “no-code” development environments to make these products as egalitarian as possible so that experienced and young developers of Robotic Process Automation (RPA) can create and automate them can use robots.

Let’s put UIPath’s low-code approach to the test by creating a number guessing application using its RPA programming tool.

First, install the IDE and build a basic UiPath Hello World application to get familiar with the tool.

How to Learn RPA Programming

An RPA programmer must learn the following in order to master the basic principles of RPA development:

  • Variable initialization techniques;
  • Conditional logic with if-then-else statements;
  • Iterative logic using for, each, and while loops;
  • Interactive input and output routines; and
  • The use of try-catch blocks to implement UiPath error handling.

After an RPA programmer masters the above building blocks, it won’t be difficult to create UiPath robots to perform invoice data extraction, OCR image processing, or email automation.

RPA project creation

All RPA programming in a UiPath studio starts with creating a new project. In this UiPath Studio tutorial, we have a new UiPath process project called. started RPA number Guesser.

Use a number puzzle game to learn RPA programming.

Variable initialization in UiPath Studio

The application requires three variables, which means the Multiple assignment Activity must be drawn from the activities Tab on the main workflow window. Use this activity to create the following variables:

  • A variable called number of type int32 – initializes it to the number 0;
  • A variable called secret key of type int32 – initialize it to 5; and
  • A variable called suspect of type int32.

The secret key will be the number the user is trying to guess. The number will keep track of the number of guesses. The variable named suspect saves the user’s entries temporarily.

multiple_assign_mobile An introduction to RPA programming with UiPath Studio

UiPath Studio provides an activity to initialize multiple variables at once.

UiPath Studio do-while loops

In order to iteratively prompt the user to guess the PIN, a programmer must put a do-while loop under the Multiple assignment Activity. The loop continues as long as the secret number is not equal to the user’s guess, which means the following logic is entered for the condition of the loop:

rate secret numberN

Insert in the do-while loop. added Input dialog Activity to prompt the user for a number and store the answer in the variable suspect.

Assign the following values ​​for the input dialog:

  • Put the label on “Choose a number between 1 and 10“.
  • Put the title on “What will you choose“.
  • Put on the result suspect.

Right after the program asks the user to guess, paste. added Assign Activity and increase the number. By doing Assign Activity setting number to count + 1.

Conditional statements from UiPath Studio

Because the user’s guess is stored in a variable, the application requires conditional statements that direct the user to guess higher or lower as necessary. Start the conditional logic by adding If Activity on the sequence.

This first If Statement simply checks that the user guessed the correct number. Add the code to the condition of the If Activity as follows:

rate secret numberN

By doing Then Clause, add a nested If Condition and indicate whether you want the user to guess higher or lower. For the state of the nested If, check if the guess is less than the secret. Add a Message box to both Then and Otherwise Conditions that direct the user to guess higher or lower.

if_condition_mobile An introduction to RPA programming with UiPath Studio

RPA programmers typically use nested if-clauses in their code.

Complete the RPA programming app

The final operation added to our application is to: a Message box Activity after Do while Activity that tells the user how often it took them to guess correctly. The content of the Message box would be as follows:

“Right! You had to guess” + count.ToString + “.”

When all of this is done, a programmer can run the RPA program. The number puzzle game will play, and if the user guesses the number five, the program will trigger a window telling the user that they guessed the secret number correctly.

This is what the completed RPA programming project looks like when it is completed.

number_guesser_sequence_mobile An introduction to RPA programming with UiPath Studio

The complete RPA programming project in UiPath Studio.

UiPath exception handling

This application has a minor bug. If a user of the published UiPath app provides non-numeric input, it throws an exception. There are many ways to do input validation, but a simple solution for this example is to put the entire do-while loop in a try-catch block. A programmer can accomplish this by using the UiPath. adds Try catching it Activity on the side. Move the loop into the body of the experiment and then catch the System.exception.

Continued learning

If you want to improve your RPA programming skills, build on this UiPath Studio tutorial by creating a few projects of your own. I always recommend developers use the concepts taught here and see if they can write rock, paper, and scissors application. Completing such a project on your own will help strengthen the basics of software development and take you one step further on your path to mastering and learning RPA programming skills.

The source code for this UiPath Studio tutorial can be found on GitHub.

View all videos

July 5, 2021