Initialize or setting variables in loop

Hi,

I was wondering, if it is possible to initialize or define variables in a for each loop?

An array of strings as the following:
arrAttribute = {"brand name", "date", "amount"}

I want to define/create a variable for each Attribut in arrAttribute.
So let’s say kind of like this with an assign activity for example:

for each Attribut in arrAttribute
str+ Attribut = "Example" 

Is it possible to create the variable inside the loop without creating it before, because the array of Attributes in my process has over 40 elements. Otherwise I would have to hard code it.

Hi @titatarik

You want to join the all the values in the array?

If so you can simply use join function.

@titatarik
We can not create variables in Run Time. You need to see another possible logic for that to store these in array or dictionary

Okay, that was the question.

Then I have to create the variables maually I guess.

@titatarik yes you need to create manually but you can make it minimum by using list, dictionary and datatable…its totally up to you.

But how do I create them by using a list or dictionary?

If i can not create while runtime, how is it of use to use a list?

@titatarik

  1. Name your variable (e.g., myVariables) and set the variable type to “Dictionary” by selecting the appropriate option from the dropdown menu.
  2. In the “Edit Variables” window, you can define the structure of your dictionary. Add the desired keys (e.g., variable1, variable2, variable3, etc.) and set their initial values.
  3. Once you have defined your dictionary variable, you can access and modify its values using UiPath activities. For example, you can use the “Assign” activity to assign new values to specific keys or retrieve values from the dictionary using the “Get Dictionary Value” activity.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.