07-31-2009 03:06 AM
Hi,
I am reading some values from an ini file using a 'for loop'. This gives me an array of values which I use throughout my program. So far, so good.
I would like to take each value from the array and display it in individual indicators on the front panel.
I have solved this by using the 'array to cluster', then the 'unbundle cluster' and the output of this goes to each indicator. See attached vi example.
Although this works, I was wondering if there is a more elegant solution. In my example, I'm only using 4 values, so the 'unbundle cluster' is not very big. If I need to display say, 40 values, then this unbundle takes up three quarters of the height of my screen!
Any suggestions?
Regards.
Solved! Go to Solution.
07-31-2009 03:23 AM
Hi,
I suggest this.
Regards,
Yoann
07-31-2009 03:29 AM
Hi there
to get values of array elements use the "Index Array" function from the Array palette. Drag the upper or lower edge to add additional terminals. if you leave the "index" terminal unwired, the function returns element 0, 1, 2 .. See documentation for details.
There's no reason to convert the array to a cluster and then get the clusters elements.
07-31-2009 03:45 AM
Thanks for this reply.
Using the 'index array' function still gives a long (tall?) structure if there are a lot of elements. But I see your point of not needing the conversion to a cluster, so that's certainly an improvement on mine.
The reply from Yoann looks promising, although I can't quite see how it works. Wouldn't it just send all values in turn to the one indicator, and leave the last element displayed there at the end?
Regards.
07-31-2009 04:05 AM
Hi there
The suggestion from Yoann goes like this:
"Add a case for each indicator and place the indicator inside that case. So you would save a lot of space in the block diagram, because all the code is piled up in a case structure"
But you pay with an additional for loop and ~40 additional if/then - decisions where all you want to do is to get some array elements. Plus: avoid overlaying code whenever possible.