Component Arrays


ntrh1

Recommended Posts

You mean through script? Even though internally the components are objects, they aren't DAQFactory objects, so there is no way to store references to them. However, you can achieve the same affect using the component name. For example, you could name your components, LED1, LED2, LED3, etc. Then you can use the execute command in a loop. For example, if you had 3 LED's with those names, you could make them all invisible with this:

for (private i = 0, i < 3, i++)

execute("component.led" + i + ".visible = 0")

endfor

I use this technique all the time to great success.

Link to comment
Share on other sites

Don't see how there's any advantage vs your method, but you could also stick the component names in a string array (either a universal one called ComponentNames[] or specific ones like LED_Name[] and so on) and then use array notation with evaluate() or execute().

Link to comment
Share on other sites

The advantage of Steve's method is you could name the components whatever you want and wouldn't have to have 0, 1, 2, 3, etc. after them. The advantage of my method is that when you duplicate a component with a name like LED1, DAQFactory will automatically make the new component's name be LED2, incrementing the postfix number for you. This makes it super easy to create a large number of components.

The other thing I do when dealing with large numbers of similar components is to write a script using the techniques described to actually place the components, since often the components are arranged in some sort of order that makes it easy to calculate their position using the index.

Link to comment
Share on other sites

The advantage of my method is that when you duplicate a component with a name like LED1, DAQFactory will automatically make the new component's name be LED2, incrementing the postfix number for you.

Very cool! I didn't know that -- thanks for the tip! I'll definitely use that.

Link to comment
Share on other sites

I've done a thing with displaying large arrays that reminds me of how you place the elements programmatically. Resolve which row and column you are by MyComponent.PositionTop/Left in conjunction with constants that store the top/left of the display area and row or column pitch, then index into the array to get the value to display. You can duplicate the display objects and just by moving the new set to their correct position, they automatically display a different array element with no additional editing. You can add a whole new row in like four seconds. Weird sensation if you grab the whole table and move it, the values change as you move it, until you adjust the constants holding the top and left edge dimensions.

Link to comment
Share on other sites

Archived

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