LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I use data value references with a functional global?

Solved!
Go to solution

@tst wrote:

I can't play with the code, so I can't comment on a bug or no bug, but you should definitely pass the reference back into the SR. If for some reason the type propagates incorrectly (which shouldn't happen), you can use a typecast to force the reference back to its correct data type.

 

Also, you should probably move the DVR creation primitive into the New case, because now you're creating a new reference with each run of the VI.

 

Lastly, the reason it didn't work independently would have to do with the way LV handles references - a reference is automatically destroyed when the VI hierarchy it was first created in goes idle, so if you run the VI by itself, the reference is destroyed as soon as the VI stops, because it's a top-level VI and having it stop makes the hierarchy go idle. This is relevant to all types of references (including the .NET references mentioned earlier).


Agreed!

 

This is the same situation I described in my Nugget on creating an Array of Occurneces found here where I wrote;

 


 

There is one last point that I would be negligent if I did not mention. It is the “good little assistant” nature of LV can get carried away if we do not take into consideration the lifetime of the resources of a VI. The resources that affect the illustrated OBA are the Occurrence itself. The Occurrence is valid only as long as the VI that holds the GO is active. If we closed the reference to the sub-VI’s used to create the Occurrence references in the For Loop where they are created, the Occurrences would go invalid before they were ever used. To prevent the Occurrences from going invalid, all of the VI references are closed only when the application no longer needs the Occurrences.

 


 

This has been the case going back to about LV 6 or there-abouts.

 

Prior to the "Clean-up" routine references would stay alive when the VI stopped and this was BAD because if a file was involved (opened but never closed) we would have to re-boot the PC to release the lock.

 

So the clean-up routine is truely a "good little assistant" and we just have to learn that it will clean-up our toys when we are done.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 11 of 11
(674 Views)