Discussion:
property nodes vs reference
(too old to reply)
Manc Pablo
2008-08-14 09:40:19 UTC
Permalink
Gurus, Attached is a simple program that does nothing but illustrate my questions. What is the difference between changing/updating information/variables etc by reference and by property node? And which should be used under what circumstances? I have some controls/indicators that will be updated from several locations, sometimes disabled/enable and sometimes blink, so I am using a variety of properties for a single element. Having looked at the help pages, I am confident I understand the difference between property nodes and local variables. P 


property node vs reference.vi:
http://forums.ni.com/ni/attachments/ni/170/349239/1/property node vs reference.vi
cschneider
2008-08-14 11:40:06 UTC
Permalink
Hi, the behaviour of a reference is difference from the behaviour of a property node. You can use property nodes to change attributes of a control, like blinking, color etc. You have to use a reference to a control if you want to access these properties from another vi. You can pass a reference by a connector pane to another vi, wire it there to a property node and access the properties of a control which is not part of the active vi.  Hope this helps, Christian
Manc Pablo
2008-08-14 12:10:04 UTC
Permalink
Yeah, it does. So a reference it is a bit like a global variable but with the bonus of changing more than just the value? Does the reference option have any similarity to pointers in other languages? P 
Ben
2008-08-14 13:10:07 UTC
Permalink
Manc Pablo wrote:
Yeah, it does. So a reference it is a bit like a global variable but with the bonus of changing more than just the value? Does the reference option have any similarity to pointers in other languages? P 
Yes, but don't get caried away! Refernces to controls are like file references where they are a number that lets the environment located a resource. But as you may have seen if you share a ref to a file across multiple threads, there are possiblities of race conditions if the access to the resource is not protected in some way. LV protects the resource by using the UI thread (single threadded) to help but if you don't pay attention to reace-conditions you will run into trouble. But now to the critiacl point. Many converts to LV get the idea that locals (or control references) in LV are like locals in C and use them in a manner similar to what is typically done in text languages as named variables. Named variables in C are just an easy way to keep track of a block on memory. In LV you do not have to keep track of the memory since LV does this for you. It does this for every wire you put on a diagram. In LV the wires are your buffers, memory locations etc. Or as I believe Christian has written, "The wire is the data." If you would like to keep working with your current schema you can put free lables over your wires while you are making the paradigm shift to the dataflow. Controls and indicatrs should not be used for storing or sharing data except in the most simplistic cases. Use your wires to move data from operation to operation. If the data is to be shared, use Functional Globals (also called Action Engines) Queues, etc. I hope I am not sounding preachy with this post. I just want to make sure you don't make the mistake I did when I converted from C to G.  Ben
muks
2008-08-14 13:10:06 UTC
Permalink
 
the behaviour of a reference is difference from
the behaviour of a property node. You can use property nodes to change
attributes of a control, like blinking, color etc. You have to use a
reference to a control if you want to access these properties from
another vi. You can pass a reference by a connector pane to another vi,
wire it there to a property node and access the properties of a control
which is not part of the active vi.
  Nice and crisp explanation. 
Loading...