Dynamic variable name possible?

Hello everyone,

I have the following 2 arrays from type string:
Status01 with value {“Test1”;“Test2”}
Status02 with value {“Test3”,“Test4”}

My question is, if it’s possible to change the name of the variable if I use them in a for each row in dataTable activity?

In my for each row in dataTable activity, I have the following single activity:

Rename File:
“\TestServer\TestFolder"+Status01(0)+”.XLSX"

Can I change the name from Status01 to Status02, without adding a new Rename File activity, if it changes the row? It needs to change the number in the variable Status01 to 02.

Thanks in advance and I hope my case was clear to understand,
Dennis :slight_smile:

You should use a dictionary. Then your variable names become the key names, which you can easily reference via variable:

someVar = “test”
myDict(someVar).ToString

This will return myDict(“test”)

1 Like

Hi,

Can you try as the following?

dict = New Dictionary(Of String,String())From{{"Status01",{"Test1","Test2"}},{"Status02",{"Test3","Test4"}}}

Then

"\TestServer\TestFolder"+dict("Status02")(0)+".XLSX"

Note: dict is Dictionary<String,String[]> type

Regards,

1 Like

Thank you!!! This worked very good.
I am happy that my case was clear enough :wink:

1 Like

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