LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Check DVR reference valid not null

Solved!
Go to solution

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



Using LV2018 32 bit

Highly recommended open source screen capture software (useful for bug reports).

https://getsharex.com/
0 Kudos
Message 1 of 7
(4,042 Views)

Can you post an example for this?

Working with LV 2013f2, so no SP1!, i cannot reproduce this...

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 7
(4,025 Views)

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:

 

DVR ref bug.png



Using LV2018 32 bit

Highly recommended open source screen capture software (useful for bug reports).

https://getsharex.com/
Message 3 of 7
(4,021 Views)
Solution
Accepted by topic author matt.baker

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

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 7
(4,019 Views)

Thanks Norbert. Forgot about that function 🙂

Think I will file a bug report as well.



Using LV2018 32 bit

Highly recommended open source screen capture software (useful for bug reports).

https://getsharex.com/
Message 5 of 7
(4,012 Views)

@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.

Rolf Kalbermatter
My Blog
Message 6 of 7
(3,972 Views)
Good info rolfk. Thanks for clarifying this.


Using LV2018 32 bit

Highly recommended open source screen capture software (useful for bug reports).

https://getsharex.com/
0 Kudos
Message 7 of 7
(3,958 Views)