06-08-2011 09:41 AM
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"?
Solved! Go to Solution.
06-08-2011 09:48 AM
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.
06-08-2011 10:01 AM
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.
06-08-2011 10:14 AM
Have the called VI open a ref to itself.
Ben
06-08-2011 01:05 PM
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.
06-09-2011 08:11 AM
@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!