03-17-2014 07:58 AM
I have recently upgraded from LV2009 straight to LV2013 SP1 and noticed that it is no longer possible to compare a DVR reference to "Not a Refnum" data type. How can you check if a DVR is valid/already created?
Thanks
Solved! Go to Solution.
03-17-2014 08:26 AM
Can you post an example for this?
Working with LV 2013f2, so no SP1!, i cannot reproduce this...
Norbert
03-17-2014 08:38 AM
A-ha! I have just accidentally reversed the inputs of the “Equal?” function while creating this example and noticed the wire break went away. If it is changed back to DVR == Not a refnum, it breaks again. See image below:
03-17-2014 08:45 AM
This is a rather odd behavior i can see in LV 2013f2 as well..... on the other hand, i recommend you to use the "Not a Number/Path/Refnum?" function on the comparison palette.
Norbert
03-17-2014 08:55 AM
Thanks Norbert. Forgot about that function 🙂
Think I will file a bug report as well.
03-18-2014 05:35 PM - edited 03-18-2014 05:42 PM
@matt.baker wrote:
Thanks Norbert. Forgot about that function 🙂
Think I will file a bug report as well.
Not a Number/Path/Refnum is definitely the prefered way to do this, unless you specifically only want to check for the refnum to never have been initialized.
The difference is this:
refnum never opened (or more precisely ever passed to this control) will result in the refnum equal to NULL and that is the same as a comparison to the Not a Refnum constant. (TRUE)
refnum opened and passed to the control and still valid will also result in the same result for both comparisons. (FALSE)
The difference happens if you have opened the DVR (or any other refnum) at some point which will result in the intrinsic numeric value that represents the refnum being a non-NULL magic cookie. If you then close the refnum somewhere else in your program, either explicitedly or because the top level VI in whose hierarchy the refnum was opened/created goes idle, the refnum will be not valid anymore but the numeric value stored in the refnum wire will still be non-null. Here your comparison will result in FALSE while Not a Number/Path/Refnum will correctly return TRUE.
Note: This is true for all native LabVIEW refnums including VISA refnums, but doesn't apply for the artificial refnums that abused the datalog refnum type to create a specific refnum type that could not be connected to any other refnum type. The old LVOOP refnums were such refnums as were other refnums such as the old synchronization VIs before the Queue, Semaphore and Rendevouz were changed into native nodes.
03-18-2014 06:21 PM