LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Disabling clusters of an array of clusters

Solved!
Go to solution

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

0 Kudos
Message 1 of 7
(3,269 Views)

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. 

0 Kudos
Message 2 of 7
(3,266 Views)
It's the Reshape array that's the culprit. Since you reshape it to have 2 elements/row, you cant add 1 element, only 1 row (thus 2 elements).

Dont mix up presentation with calculation, if you dont want 2 elements at a time, dont make a 2 column row. 😉
Clean and good code, btw. But there's no need to rebuild the array through a loop to add the elements (side effect of your reshape), you can reshape it back if you want to keep that solution.
/Y
Message Edited by Yamaeda on 03-14-2010 02:11 PM
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 7
(3,255 Views)

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

0 Kudos
Message 4 of 7
(3,234 Views)
Solution
Accepted by dan07

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

 

 

LabVIEW 5.0 seems so long ago...
Message 5 of 7
(3,225 Views)

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.

Message 6 of 7
(3,224 Views)

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

0 Kudos
Message 7 of 7
(3,179 Views)