03-14-2010 04:56 AM
I've been using array of clusters in some VIs but I have two problems when working with odd number of elements. The attached VI shows the problems that I have. The VI will generate as many random numbers as specified in the "N of elements" control, and show all numbers in indicators inside clusters. Also in the clusters there is a Led that is used to "use" or "not use" the value in the cluster for the final "Sum".
I have two problems:
First: When I have an odd number of elements (9, for example), the 10th cluster (located at the 5th line) is highlighted, but I want it gray since I don't have anything to show there.
Second: If I have 10 elements and I click on the led of the 11th cluster (6th line), the 11th and 12th cluster highlight. How do I prevent this?
Thanks
Dan07
Solved! Go to Solution.
03-14-2010 05:21 AM
To solve the second problem I was thinking about:
After the user clicks on a led of a cluster, the number of elements of the array of clusters will me changed (array size). So, I can do somethink like this:
- If the number of clusters (evaluated by the array size VI) is greater than the number of elements previously generated, disconsider this change of the led state and write to the array of clusters its value of the last loop iteration
- If the number of clusters (evaluated by the array size VI) is equal or lower to the number of elements previously generated, consider the user change of the led state and use this information to generate the final sum.
Was just an idea.
03-14-2010 08:09 AM - edited 03-14-2010 08:11 AM
03-14-2010 02:38 PM
Hello. I understood what you say, but for my code is very important to have a two columns indicator. Do you have any suggestion to solve this issue and keep the two columns?
Your suggestion will solve my first problem, but how about the second? Can I use the "array size" trick (as I wrote above) to fix the second problem?
Thanks
Dan07
03-14-2010 06:35 PM
I'm not certain I completely understand the functionality you want.
However, I've added front panel & code in parallel with a possible solution.
Hope this is useful
James
03-14-2010 06:37 PM
One problem is that you are using a control for what essentially seems like an indicator. So if you click on an unused element, it becomes a new element in the array and all elements leading up to that get filled in as well.
2-D arrays must be rectangular. You can't have column 0 with 5 elements and column 1 with only 4.
You say it is important to have a 2 column indicator, but what is the meaning of a row where only 1 column has a value?
If you do want something like that, then perhaps you need to display it as two 1-D arrays.
03-20-2010 12:53 AM
Hello guys
The two columns indicator is important for me, but it will be impossible to use the 2D array. I will follow your advice and go with two 1D arrays.
Ravens Fan, sometimes I have odd sometimes I have even number of elements. That's the reason for a row with only 1 column with a value.
Thanks all.
Dan07