Increment component name?


Recommended Posts

Hi,

I'm new here, I searched the forum but didn't find what I was looking for. Hope you can help me.

I want to be able to change a component property for multiple components like this:

Component.comp1.visible=V.compcount[127]

Component.comp2.visible=V.compcount[126]

Component.comp3.visible=V.compcount[125]

Component.comp4.visible=V.compcount[124]

Component.comp5.visible=V.compcount[123]

...

but I have 128 of them and wouldn't like to have to write each assignement one by one.. Is there a way I can do this using a for-loop or something like that? Or could you perhaps propose another solution to my problem?

Hope that my question is clear.

Thank you in advance

Link to comment
Share on other sites

Your question is clear, as is the answer: use the execute() function and create the command string dynamically. Something like this:

for (private i = 1, i < 128, i++)
   execute("component.comp" + i + ".visible=V.compcount[" + 128-i)
endfor

Note that since I start with a string, I don't have to use doubleToStr() to convert the numbers, the string concatenation operator handles it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.