0% found this document useful (0 votes)
45 views3 pages

Experiment 2

Hi

Uploaded by

Ramesh H
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views3 pages

Experiment 2

Hi

Uploaded by

Ramesh H
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Robotic Process Automation Design and Development (UiPath) BCG701

2. Develop automation in UiPath StudioX to demonstrate the following activities: if,


Switch., Repeat Number Of Times. , Skip Current, Exit Loop.

The automation will loop 10 times, asking you to guess a number. Your input will trigger
different actions based on the control flow activities.

Step 1: Project Setup and Loop

First, create the project and the main loop that will drive the game.

1. Create Project: Open UiPath StudioX and select Blank Process. Name it
ControlFlowDemo and click Create.
2. Create the Loop: Drag a Repeat Number Of Times activity into the designer panel.
o In the Number of repetitions field, enter 10. This means the game will give
you a maximum of 10 tries.

Step 2: Get User Input

Inside the loop, we need to ask the user for their guess in each iteration.

1. Add Input Dialog: Drag an Input Dialog activity inside the Repeat Number Of
Times activity.
2. Configure Dialog:
o Dialog Title: Type "Guess the Number!".
o Input Label: Type "Enter a number between 1-5. (Enter 0 to exit, 5 to skip a
turn)".
o Value entered: Click the Plus icon > Create Variable. Name the saved value
userGuess and click OK.

Step 3: Use 'If' to Handle the Exit Condition

Now, let's add a way for the user to quit the game early using an If condition and the Exit
Loop activity.

1. Add If Activity: Drag an If activity inside the loop, just below the Input Dialog.
2. Set Condition:
o Click the Plus icon in the Condition field and select Condition Builder.
o Set the condition to: Use Variable > userGuess equals 0. i.e
Int32.Parse(userGuess) == 0.
3. Configure 'Then' Block:
o Drag a Message Box into the Then section. In the Text field, type: "Exiting
the game now. Goodbye!"
o Drag an Exit Loop/Break activity below this Message Box. This will
immediately stop the Repeat Number Of Times loop.

Dept of CSD, TCE, Gadag Prof. Santoshkumar Merwade


Robotic Process Automation Design and Development (UiPath) BCG701

Step 4: Use 'Switch' for the Main Game Logic

In the Else section of the If activity, we will use a Switch to handle the different guesses.

1. Add Switch Activity: Drag a Switch activity into the Else section.
o Expression: In the Expression field, click the Plus icon > Use Variable >
userGuess.
2. Add Cases:
o Winning Case (Case 3):
 Click Add new case and type 3 in the Case value field.
 Drag a Message Box into this case and type: "Correct! You found the
secret number!"
o Skip Case (Case 5):
 Click Add new case and type 5 in the Case value field.
 Drag a Message Box into this case and type: "Skipping this turn as
requested."
 Drag a Skip Current/Continue activity below the Message Box. This
will immediately end the current iteration and start the next one.
o Default Case (Wrong Guess):
 Drag a Message Box into the Default case section.
 Type: "Sorry, that's not the secret number. Try again!"
3. Add Final Message: After the entire Repeat Number Of Times activity, drag one
final Message Box and type "Game Over! Thanks for playing."

Run the Automation

Click the Run button. The automation will now execute the game logic you've built.

 Entering 3 will show the "Correct" message.


 Entering 5 will show the "Skipping" message and the loop will continue to the next
turn.
 Entering 0 will show the "Exiting" message and end the entire loop.
 Entering any other number will trigger the "Default" case message.

Dept of CSD, TCE, Gadag Prof. Santoshkumar Merwade


Robotic Process Automation Design and Development (UiPath) BCG701

Dept of CSD, TCE, Gadag Prof. Santoshkumar Merwade

You might also like