LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem Using Value(Signaling) with Latching Boolean ver 2017(sp1)

Solved!
Go to solution

I searched and couldn't find an answer to my problem. What I am trying to do is to exit a subVI by allowing the user to click either the "exit button" or the "Panel Close".

 

I have some housekeeping code in the Exit case that needs to be done regardless which button the user clicks. So when the user clicks the Panel Close, I wire a True to the Discard? event filter and use Val(Sgnl) to generate an event to execute the Exit case. This worked just fine in LabVIEW versions 2016 and prior. I tried to do this in ver 2017 (sp1) and it doesn't seem to work.

 

BlkDiag.png

 

In 2017(sp1), the Val(Sgnl) Data Type is now Variant Data. When I try to write to the property, nothing happens. The property throws an error and NO event is generated. The help file says that you cannot READ from a latched Boolean. Doesn't mention anything about writing to a latched Boolean. What do I need to do different to get this to work in ver 2017. I guess I could create a dynamic event, but the old way was a lot easier.

 

error.PNG

 

ValSigTitle.PNG

Latch.PNG

0 Kudos
Message 1 of 8
(3,136 Views)
Solution
Accepted by topic author jamiva

You are wrong. This property was never allowed for latching booleans.

Change to switching and reset the boolean by code when required.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 8
(3,124 Views)

@pincpanter wrote:

You are wrong. This property was never allowed for latching booleans.

Change to switching and reset the boolean by code when required.


You are correct that it was not allowed, but occasionally (rarely) it would work, although I can't recall how or why.  One way I got around it in LV2016 was to typecast the latched bool to a switched bool.  This doesn't work in LV2017, though.

0 Kudos
Message 3 of 8
(3,120 Views)

Please have a look into a proper state machine architecture.  With that kind of setup, both events (button press and panel close) would redirect to an Exit state to run the cleanup code.  And if you decided to add a third method for exiting the program or if you have a critical error that requires program to exit, it's easy to do this by redirecting to the Exit state.  I'm assuming that your cleanup code is located within the Exit button event because otherwise, there would be no need to force that event to occur thru property nodes.  My suggestion is to keep the event structure very simple and mostly free of code so that it is free to process UI events. 

 

Spoiler
You might want to check out the JKI State Machine template.
aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 4 of 8
(3,117 Views)

I was not aware of this trick. I find it a little dangerous, though. There must be a good reason why latched boolean cannot be read/written by code.

However, it is not necessary to do a hack, as a straightforward workaround is available.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 8
(3,114 Views)

Put all your cleanup code in the "panel close?" event and eliminate the exit button completely. One way to close the program is sufficient. Everybody knows the functionality of the [X] in the upper right corner, so that's the preferred and standard way.

 

A typical windows program does not have an [Exit] Button in some random location of the panel. It's not natural to have one. It just wastes valuable panel space.

Message 6 of 8
(3,106 Views)

 


I was wrong. You are all correct about not being able to use the Val(Sgnl) on a latched boolean. I should have looked closer at my old code.

 

The old code used TWO booleans and both were specified for the Exit event: one was latched (visible to user), and the second was switched (hidden from view). But it was the switched boolean that I used with the Val(Sgnl). Learned my lesson. Next time I won't use similar names for two different controls: "Exit(button)" and "Exit"

 

altenbach: It wasn't my idea to have two ways to exit the popup window. I originally had one, but got overruled.

 

Thanks for all your help

 

0 Kudos
Message 7 of 8
(3,085 Views)

@jamiva wrote:

 

altenbach: It wasn't my idea to have two ways to exit the popup window. I originally had one, but got overruled.

 


OK, I wasn't aware that this is a popup, and yes, if the specs require something, you have no choice. 😞

Typically a popup has an OK and cancel button, [OK] tied to the enter button and [cancel] tied to the escape button. Pressing the [x] should be equivalent to cancel.

Of course functionality can differ significantly. 😄

Back to the original problem, there is also this old idea, of course.

0 Kudos
Message 8 of 8
(3,075 Views)