LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about Arrays

Solved!
Go to solution

Hi,

In the attached VI, when a boolean from BooleanArray is True, that row is highlighted. When the clear button is pressed, all highlighted rows are cleared. The next time the array changes (triggered by the event structure), the Trued booleans are highlighted again.

I would like to be able to highlight only the boolean that were not True before the clear button was pressed. In other words, I only want to highlight new booleans.

I think of shift registers, but I am not sure how to implement that in here.

 

Thank you for your help.

0 Kudos
Message 1 of 31
(3,343 Views)

Can you reset all your booleans after the clear is pressed by Anding it with a false.  Attached is an update.

 

Or you could try on triggering the value change of the booleans, XOR it with the old value, and only update the row that has changed.

Message 2 of 31
(3,330 Views)
Solution
Accepted by topic author TeamHalli

Shift register is correct. Every time the Clear button value change event is triggered True, pull the current highlighted cells in the form of an array and write them to a shift register. Every other event case should just pass this array through without changing it. The event when BooleanArray changes should pull in the array of cleared rows and not highlight those.

 

Make sure that if you clear again after already clearing, you append the new cleared values.

You will also need to take in to account when a previously cleared value is changed... so that would require you to edit the cleared values and remove one if it changes value...

 

 

 

Hooovahh's second idea is what you want. See attached.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 3 of 31
(3,325 Views)

Yeah I probably should have used a shift register in my posted VI, but to be honest I wanted to be quick to the reply to beat James. Smiley Tongue

0 Kudos
Message 4 of 31
(3,311 Views)

Haha, and you did beat me because I was overcomplicating it. I posted before really understanding how the highlighting was working. The listbox itself is acting as the shift register (memory) as long as all he wants to do is highlight the new True values. It was redudant in the code by marking all true values green every time.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 31
(3,302 Views)

Hi TeamHalli,

 

I think you can compare the old value and new value in the event case to determine which element is changed in the boolean array.

And then feed the compared result into the for loop to determine whether it should be highlighted or not.

 

 

20151015001.png

0 Kudos
Message 6 of 31
(3,299 Views)

Hi TeamHalli,

 

After reviewing your post, I think "Less than" operator is more appropriate to your case...

By the way, it might be better to initialize the boolean array first.

20151015002.png

0 Kudos
Message 7 of 31
(3,295 Views)

Just a few final comments:

 

  • The clear button should be "latch when released" (not "switch until released").
    • now you can remove the case structure in the event case because the event only fires when it is true
    • With your setting it fires twice (on press and on release). too much work.
  • You need to find a way to align the listbox rows with the booleans. Make sure you use a defined font for the listbox or the alingment will potentially change on other computers.
  • To only highlight the new booleans since the last clear operation, you could just also clear the boolean array, for example. Else you would need a helper array in a shift register to keep track of which elements to ingore.
  • There is no natrual way to stop the VI.
  • You could eliminate the boolean array completely and use value change events on the listbox instead. This would also eliminate the alignment issues.

 

0 Kudos
Message 8 of 31
(3,274 Views)

Thank you all for your suggestions. Would it be possible to have the highlight flash green/clear instead of it being a steady green?

Your help is greatly appreciated! 

0 Kudos
Message 9 of 31
(3,237 Views)
Yeah, you could just add a little code where you set the color one way and then back again with a small Wait in the middle.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 10 of 31
(3,223 Views)