LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I assemble an array based on a button cluster?

I have a cluster of buttons that I would like to use to select what elements to pull from an array of constant strings and output an array containing only the "on" selections.  I tried converting the booleans to 0's and 1's, then putting it through a min/max selector.  I also tried using the Search 1D Array function.  Neither of these worked right. The program ran, but did not output all the strings (nor the correct ones, sometimes), usually limiting itself to 2 elements.

 

 

Does anybody have any ideas?  Thanks!

 

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

Hi Johnsoda,

 

Just a few comments on your program.  The stacked sequence is not a good architecture to get in the habit of using.  It hides code!  Because you used the stacked sequence you had to use a local variable to transfer the PATH data, you could have just wired it up directly.  You used a while loop, I think to force a wait in the program.  This while loop will take control of your processor, probably not what you were going for.  You would be better off using a wait(ms) function on the timing pallette.  I will take a crack at showing you a different way to write this code.

 

 

Message 2 of 7
(3,310 Views)

Hi jmcbee,

Thanks for looking into it.  Also, thanks for the code critique - I realize that's not a good way of doing things, I was just throwing that in there for debug purposes.  The actual program won't really have the same archatecture as this program apart from the logic on how to get the button input to translate into an output array.

 

Thanks again!

David

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

Hi David,

 

No problem, a code critique is the best way to learn!  Someone will probably critique the code I give you and we will both learn from it, its the great thing about this forum.  See below for a different way to solve this problem.  And let me know if this code does not solve your problem, as it is possible I missed the boat.

 

Regards,

Jon 

 

(I am not able to add an attachment to the post right now for some reason...  I will try again in a min.) 

Message 4 of 7
(3,295 Views)

In addition to the above comments:

 

  • Your method for initializing the cluster is one step too complicated. The Insert Into Array is not necessary. All you need is the Initialize Array function wired to the Array to Cluster function. Simply wire the correct value to the dimension size input.
  • You should not auto-index a loop and wire to the N input simultaneously. 
  • Your string indicator will end up showing the last selected element. 


A simpler way to do what you're trying to do is to autoindex the array of Booleans with the array of strings and build your string that way.

 

Note that instead of using a fixed array of strings you can access the cluster's element names via property nodes, though that may be a bit advanced for you at this point. Smiley Wink

 

EDIT: Was writing reply while previous 2 posts were put up. See what Jon provides you.

Message Edited by smercurio_fc on 09-23-2008 10:43 AM
Message 5 of 7
(3,282 Views)

I cant seem to attach the VI, 

 

here is a screenshot

 

 

Message 6 of 7
(3,280 Views)

Thanks to both of you!  I ended up using a combination of the two and it seems to work great.  Thanks so much!

David

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