A text or string variable is a type of variable that can store only strings. These types of variables can be used to store any information such as employee names, usernames or any other string.
All strings in UiPath have to be placed in between quotes.
To exemplify how you can work with text variables, we are going to create a project that asks for the user’s name, stores it and displays only the first letter of his name in the Output panel.
- Create a sequence.
- Create two simple string variables,
- Add an Input Dialog activity to the Designer panel.
- In the Properties panel, in the Label field, type "Type your full name please.".
- In the Title field, type "What is your name?".
- In the Result field, add the
StrFullNamevariable. This variable stores whatever the user writes when prompted with the Input Dialog activity.
- Add an Assign activity under the Input Dialog one.
- In the Properties panel, in the To field, add the
- In the Value field, type
strFirstLettervariable is assigned the new value created by the
This field uses the
Substring() function to find the first character from the string added by the user in the Input Dialog.
- Add a Write Line activity under the Assign one.
- In the Properties panel, in the Text field, enter the
strFirstLettervariable. This means that the Output panel is going to display the first letter of what the user wrote in the Input Dialog. The project should look as in the following screenshot.
- Press F5. The What is your name? window is displayed.
- Type your name in the text field and click OK. In UiPath Studio, in the Output panel, note that the first letter of your name is displayed.