12-04-2006 03:58 PM
12-04-2006 04:07 PM
Hi Nick,
I wrote about this years ago and I suspect your suspicions are correct.
The value stored in the global or LV2 is still there but the validity of the "value" is what changes if the top level VI containing those goes idle.
This is good thing. (back in the old days if you forget to close a ref to a comm port, or a file, you had to re-boot the computer to free-up the resource).
What I believe is happening is LV is doing us a favor and it cleans up the mess we leave whe we are done playing.
So if you want to keep those refences alive then the widget that holds them has to keep running.
Ben
12-04-2006 04:17 PM
12-04-2006 07:50 PM
I am not sure if I follow you completely on your work-around.
Everything I have to say on this topic is based on obesrvations and threads I have read on Info-LabVIEW. Therefore it is subject to corecttion by those who know better.
LV is smart enough to know when "something" that had been opened, can be closed. It is not perfect.
If for instance you open a VISA refnum and pass the refnum to a LV2 AS A REFNUM the refnum in the LV2 stay alive as long as the VI's are running.
If you start another VI that uses the LV2 to fetch the refnum, it should get a valid ref as long as it starts before the first goes idle.
You then be able to work with refnum usign the VI launched second as long as stays active.
I often create action engine that can be invoked where required throughout an application. If the action engines get a ref in one state (like init) and use it another, I will generally write a "tester" that calls the action engine action to test the engine. In this case, my "tester" stays live and it keeps the ref's fresh.
I suspect if you tried to trick LV you could. If you type cast the ref nums to I32 and stored those in a LV2, I could see how LV could loose track of the resource sharing, but that is something I would avoid.
So I encourage you to do some experimenting with keeping track of who's running when to see if your work-around will work.
If you think you understand it better than I explained it, please post.
Trying to help,
Ben
12-04-2006 08:09 PM