Multiple values for one parameter in the config file

Hello,

I want to know can I set multiple values or a list of values for one parameter in the config file (setting sheet)? For example list of string that requires several rows if you write in a text file or an excel file

Hey,

sure you can set multiple values for one parameter in the config file. Just separate them by a comma (or any other character you like). Then you can split those values into an array.

Example: Check if MyString is in the list I put into the Config file named MyList:
in_Config("MyList").ToString.Split(","c).Contains(MyString)

Does this help?

Cheers, Lukas

1 Like

Hi,

thank you for the idea. I will try it first in my project and will let you know if it work.

Thank you.

Regards,
Aoyama

I suggest using json format for an array.
[ 1,2,3,4,5 ]
[ "a","b","c" ]

So it can be either numbers or strings or dates, etc

And, in your Init Settings when you add it to the dictionary, you would need to check if it is an array, and store it accordingly.

When you use it, you would need to change the type to an array of object.
CType(config("key"),Object())
to change them to string, then CType(config("key"),Object()).Select(Function(x) x.ToString)

this is how you would first set it to the dictionary. In the catch, you just store it as a string
image

I like this method, however I do wish I had it working more simpler, where you don’t need to convert a jarray to a regular array.

The split method works, but I feel it might be more relaxed on the format or delimiter that one chooses to use.

Regards.

1 Like

Also, want to add that if the value only has one item but still requires an array, then you will probably need to use a condition. Like, this: If(config("key").ToString.Contains(","),config("key").ToString.Trim.Split(","c),{config("key").ToString.Trim})

You have thought of everything again like always Clayton :smile:

I’ll keep this in mind, should my simpleton code not suffice :sweat_smile:

Thanks for sharing!

1 Like

@lukasziebold @ClaytonM
I can agree to Claytions Statement and JSON serializing Strings are a really good working option

I was looking for the same and did some experiments. So also a dicitionary, some middle complex datastructures can be transported via config excel as well and worked fine for us

Thank you so much for the sharing @ClaytonM @lukasziebold @ppr
I’ll try it first for my project and will let you know if it work.

Regards,
Aoyama

Just a reminder that Strings.Split won’t throw an error if the delimiter is not found in the input string. So if the config only has one item, it would simply create an array with a length of 1 - no need for inline if statements

1 Like

oh really? I was assuming the split would keep it a string if it had nothing to split, but i didn’t double check. thanks for clarifying

1 Like