04-14-2016 09:22 AM
I have some code with a VI Key Down event that toggles visibility of some indicators in response to pressing function keys. Using Boolean shift registers, the code was working with a couple of indicators.
To scale to a large number of indicators, I decided that I'd need to convert to a single Boolean array shift register.
With the Boolean array shift register, for a given function key, the code inverts a Boolean from the array for the Visible property node, then replaces the same element in the Boolean array with the inverted Boolean. The code isn't working. Once the indicator is visible, it won't go invisible on the next button push.
I watched execution, displaying values. It looks like the Replace Array Subset VI isn't replacing the Boolean with the updated value. In the attached screenshot, you can see where I retrieved the element from the array after it was "updated" by Replace Array Subset VI. Couldn't find any related bugs in the LV2013 bug list.
See the attached screenshot. What's wrong with this code? Apologies for the resolution of the screenshot. If necessary, I'll go back to the lab and try to capture a higher resolution screenshot.
Solved! Go to Solution.
04-14-2016 09:32 AM
Maybe it's a race condition?
04-14-2016 09:47 AM
From your screen shot your boolean arrayis empty, that is, it has no elements. Replace array subset will not work with an empty array.
Cheers,
mcduff
04-14-2016 10:42 AM
@MinerHokieRamp wrote:I If necessary, I'll go back to the lab and try to capture a higher resolution screenshot.
No, screenshots are useless, because we cannot tell what's in the other event cases for example. Simply attach the actual VI.
Yes, as has been mentioned, your execution highlighting shows that the boolean array is empty. You cannot replace something that is not there! It is difficult to tell how the code is organized, but I assume there is some initialization event case that is supposed to populate the boolean array. Is there? In that case, you need to ensure that things execute in the correct order.
04-14-2016 10:58 AM
@mcduff wrote:From your screen shot your boolean arrayis empty, that is, it has no elements. Replace array subset will not work with an empty array.
Cheers,
mcduff
Thanks. I created an array indicator and initialized it in the prior frame, then used a local variable at the input to the shift register. I could have filled the constant with False Booleans. I remember seeing the "#0" indication on the array and was thinking it had something to do with index 0. My face was red.
Sorry that I'm not allowed to post the actual VI. I'm glad you could interpret the low rez screenshot.
04-14-2016 11:04 AM - edited 04-14-2016 11:04 AM
@MinerHokieRamp wrote:Thanks. I created an array indicator and initialized it in the prior frame, then used a local variable at the input to the shift register.
Why a local variable? Just use a wire! No indicator or local variable needed.