03-01-2009 12:02 PM
I'm manipulating controls on the Front Panel of my VI. In doing this, I open a slew of references (to the VI, to the Front Panel, to its Panes, and to the objects on the Front Panel). Normally, before exiting the VI, I carefully close them (in LIFO order, of course), but a question has arisen:
I want to "export" a series of references to Boolean controls for use in succeeding VIs. No problem, while enumerating the controls (see above), I simply identify the Boolean references and build them into an array that I pass out. First question -- does anything "go wrong" if I also do a "Close Ref" in the main loop (after adding the reference to the array, of course)? [At present, I'm only doing a Close Ref on the non-Booleans]. Logic says this should be OK, as the Close Ref is mainly doing "garbage collection", and I've done a "copy" operation in building my array, but to a persistent structure.
Second question -- in my "cleanup" routine, I noticed I was "double-disposing" of the references, that is, I did a Close Ref on my array of Boolean References, but also was enumerating the entire Front Panel (as I did when I opened it) and disposing of the references that it found. Again, this should be no problem, but (in principle) I'm doing a Close Ref on two references to the Boolean control. It occurs to me that this is not really logical either -- I should be able to simply "abandon" the array of references -- although it takes up memory that can be "reclaimed" for other uses, the fact that it is an array of RefNums is a "so what" -- the contents of the array could have been a numeric or other "solid" data type.
Does this make sense? To summarize, what I'm trying to do is to "extract" some RefNums to Front Panel objects for later use. In the "extraction" process, I must open (and create references to) multiple objects, including RefNums to my "objects of interest". What I think I can (and should) do, once I've copied the RefNums I need, is to dispose (Close Ref) all of the RefNums that I opened during the extraction routine, and do something equivalent when I do the subsequent "cleanup" (which undoes any modifications I made as part of the extraction).
Comments welcome.
Bob Schor
03-01-2009 12:38 PM
I usually store the ref. at the beginning of my program, in Functional Globals, and i close them when the program does not need them any more.
I think this is the right approach. And it is simple