Jump to content

What is a RefNum


Recommended Posts

Disclaimer
The following details are oversimplified for the sake of clarity. Feel free to point out important details that aren't covered by this post.

---

There is a higher chance of finding better results by searching for "labview reference". Here are a few examples.

That said, you should be familiar with the normal data flow in LabVIEW.

  • Data goes from one end of a wire to the other.
  • A branch in the wire will create a copy in memory if either branch of the wire is changed.

Loosely speaking, a wire represents the data.

A refnum on the other hand doesn't represent the data, but the location of the data in memory (*). It is similar to a pointer in C-like languages.
This changes the behavior of the wire

  • Data still goes from one end of a wire to the other.
  • Each branch of a wire receives exactly the same value as the other (no copy is made). (**)
  • In order to access the data you need to make use of Property Nodes, Invoke Nodes and more.

The benefit is, that you can access the same value from different places in your program. Even better, this is not limited to controls.
It works for controls and indicators, VIs, objects, the project, the whole application and everything.

However, it doesn't work for variables and due to its nature, race conditions can occur if you don't take care of the execution in your program.
This is why for variables there is a more specialized type of reference, the data value reference (DVR). It allows you to access the same variable in memory from different places in your program.

There is obviously much more to it than these few points. However, the links above should give you some insight.

(*) Here is some information about the memory structure of a refnum. https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019ZT5SAM&l=en-US

(**) Technically speaking a copy is still made if you change the "value" on either branch of the wire, but since it is a pointer you shouldn't change it under any circumstances.

  • Like 1
  • Thanks 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.