Is it possible to deal with a set of parameters by putting them into an array?

The idea is next. My script calculates an integer from 1 to 3. Depending on a number I want to deal (in a certain way) with a related script parameter. Say, if script gives 1, I want to deal wtih param1, if 2 then it must be param2, etc.

In order to achieve this – is it possible to put prarn1, param2, pararm3 into any array and deal with each of them by addressing via the array index? Something like this:

all_param_array={prarn1, param2, pararm3}

If it’s doable what would be a correct syntax?

Hi @olmerk

Create a table with parameter names as strings.

p = {"p1", "p2", "p3"}

If you are going to use setParameter you’re all set as it expects string as first argument.

this:setParameter(p[index], value)

If you just want to assign new value to your parameter you can use the global environment.

p1 = 0
-- same as
_G["p1"] = 0

So you could do it like this:

_G[p[index]] = value

Thanks a lot! It worked.