LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Identifying the Changing Element in a Cluster with Event Handlers

Solved!
Go to solution

Hi all,

 

I'm learning LabVIEW for a coop position, so I'm fairly new to it. I am practicing using the JKI State Machine by creating a game of Hangman. For those who don't know what Hangman is, a player tries to guess letters of a word, each incorrect guess brings you closer to losing the game (6 wrong guesses). 

 

I had made the front panel so that the player would not have to type their letter guess, instead they would just click a button and submit their guess. I have every letter of the alphabet stored in a cluster, whenever the player clicks a button in the cluster it becomes their 'current guess', they can then submit their guess. 

 

The challenge I've come across is that I'm using an event case for every letter in the cluster, hence my event case list is very long. There must be a better solution to this rather than the brute force I'm currently using. Any thoughts?

trlee02_2-1644609924510.png

 

trlee02_1-1644609907254.png

Thanks in advance for the help!

 

Tristan

 

 

0 Kudos
Message 1 of 6
(1,183 Views)
Solution
Accepted by topic author trlee02

Use a single event case for all letters; namely the Value Change event on the cluster.

In that event case wire the "New Val" and "Old Val" to the inputs of an Not Equal comparison.  Then to a Cluster to Array function, then search the array for TRUE.  The index coming out will be the index of the clicked button in the cluster.

paul_cardinale_1-1644610482638.png

 

 

"If you weren't supposed to push it, it wouldn't be a button."
Message 2 of 6
(1,176 Views)

Hi trlee,

 

check the whole cluster for a ValueChange event:

Then convert the resulting cluster into an array and search for a TRUE in the boolean array…

 

Edit: Paul was faster than me, and shows the same using an English LabVIEW version…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(1,171 Views)

Thanks for the quick response! I'll go try that out right now.

0 Kudos
Message 4 of 6
(1,171 Views)

FYI, you can select more than one solution if you feel that more than one post solved the issue.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 6
(1,134 Views)

Since you already labelled all the buttons by their letter, expanding Paul's and Gerd's solution is simple, see below

 

snip.png

0 Kudos
Message 6 of 6
(1,110 Views)