LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

what causes a vi ref to go "bad"?

Solved!
Go to solution

I'm launching a VI template via open vi ref and invoke Run VI. This works in 2 out of 3 places in my code. The 3rd it runs for few moments then does not behave the way it's supposed to. I look at the ref and it says the ref is "bad". Besides the obvious (stopping the vi, closing the ref, etc) what else can cause a vi ref to go "bad"?

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 1 of 6
(2,531 Views)

Stopping a VI will not make the reference go bad.  Closing the ref or the VI leaving memory will cause it to go bad.  What can also cause the VI reference ot go bad in later versions of LabVIEW is LabVIEW's automatic handling of references.

 

If the VI you use to open the ref goes out of memory or goes to an idle state, LabVIEW will automatically close the reference regardless of the state of the VI referenced.

0 Kudos
Message 2 of 6
(2,522 Views)

Well that's not good news. I've noticed in highlight execution mode that the ref goes bad as soon as the calling vi quits. And the calling vi is launched via open and run vi ref as well. It doesn't behave this way if the calling vi is top-level. Any workarounds? This has to work.

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 3 of 6
(2,516 Views)

Have the called VI open a ref to itself.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 6
(2,509 Views)
Solution
Accepted by topic author PaulG.

The Run VI method has a parameter called Auto Dispose Ref.

 

Pass T to that parameter and the ownership of the reference will be transferred to the new VI, effectively making it a top level VI. Be sure to read the help for it first.


___________________
Try to take over the world!
Message 5 of 6
(2,490 Views)

@tst wrote:

The Run VI method has a parameter called Auto Dispose Ref.

 

Pass T to that parameter and the ownership of the reference will be transferred to the new VI, effectively making it a top level VI. Be sure to read the help for it first.


I've known about this for years but now I can't remember why I've resisted using it. I guess I want to be in control of all of my references. I Trued Auto Dispose and it looks like it's working the way I want it to. Thanks!

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 6 of 6
(2,469 Views)