Use loop counter as part of a variable name

Hello All,

Within my excel file i have the following columns (example)

Number_of_dir
dir_title_1
dir_name_1
dir_title_2
dir_name_2
dir_title_3
dir_name_3
dir_title_X
dir_name_X

Inside number_of_dir can be 1, 2, 3 but a max of 11. I plan to use that value for a ‘while’ loop. number_of_dir>=dirloop, at the end of the while increment the dirloop by 1 and so on.

I’m thinking that i can use the loop value to tag to the end of the variables so i can use the loop to check all the fields without having to build up the sequence

dir_name_dirloop - which translate to dir_name_1

Is this possible?

Do I need to assign all the variables first

dir_title_1 = row(“dir_title_1”).toString

dirloop

Thanks in advance for any advice :smile:

Inside type into activity make dirloop.tostring

You need not store the data in the variable. You can directly use

row(“dir_title_” + dirloop.ToString).ToString

Since posting this the penny dropped and have done it another way around.

When assigning the title set the loop there.

dir_title = row(“dir_title_”+dirloop.tostring).tostring

:smiley:

1 Like

This is exactly how I’ve done it!! thanks

1 Like

what a sync! :laughing:

1 Like

Its like one mind! haha

1 Like