LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reference vs local variable

If I have numeric control where would be advantage to use its reference intead of local variable or property?

0 Kudos
Message 1 of 26
(21,562 Views)

You don't just use a reference.  You use a property node.  It can either be implicitly connected to a control, or you explicitly call it by way of a reference wired to it.

 

Either way, local variables have better performance than value property nodes.  But the advantage to property nodes is that you can programmatically determine which controls you want to reference.  For example, you could have an array of references and programmatically loop through them to write values to each one.

0 Kudos
Message 2 of 26
(21,561 Views)

@Vasilich2004 wrote:

If I have numeric control where would be advantage to use its reference intead of local variable or property?


This question is way too open ended. Use for what, exactly???

 

If you are talking about the value of the control:

 

Typically you would wire directly to the control to use the value in your code via the wire.

 

If you need to programmatically change its value (it is a "control", so this should be rare!), you would write to a local variable of the control.

If you need the value inside an indepedent code segment elsewhere, read from a local variable of the control (but be aware of possible race conditions).

If you want to do the same from within a subVI, you would need to wire a reference of the control to the subVI and use a value property node there. (you could also use a value property to read or write from within the same diagram, but a local variable is more efficient and elegant.

 

If you are talking about any other property, you would use a property node linked to the control. (local variables are useless except for the value!). If you want to modify a property frm within a subVI, you would again wire a reference to the subVI so you can access the properties using a property node wired to the reference.

Message 3 of 26
(21,559 Views)

Typically, I wire to local variables ...

0 Kudos
Message 4 of 26
(21,551 Views)

@Vasilich2004 wrote:

Typically, I wire to local variables ...


As opposed to what?

0 Kudos
Message 5 of 26
(21,544 Views)

Is this discussion related to your recent idea?

 

You really cannot efficiently get ideas across using cryptic one-line statements. Please write up a well formulated paragraph of exactly what you are trying to do, how you are doing it, and why you think your approach is better.

 

Include an example program!

Include some images!

 

Thanks!

0 Kudos
Message 6 of 26
(21,539 Views)

not really.

at first, it is related normal language.

at second, it would be easy to use.

0 Kudos
Message 7 of 26
(21,522 Views)

 

@Vasilich2004 wrote:

Typically, I wire to local variables ...


As opposed to what?

 

I put controls and indicators in one place in left side where I have initialization step. That give more chances to avoid mistakes during initialization.

If program rectange small I don't need to use right click on local variable to find control - I just look on left side.

0 Kudos
Message 8 of 26
(21,514 Views)

@Vasilich2004 wrote:

not really.


This is not even a full sentence. What are you referring to?


Vasilich2004 wrote:

at first, it is related normal language.

at second, it would be easy to use.


What is "it"? What is "normal"? What is "easy"? Why?

 

If you think you have a magnificient idea, you need to be able to communicate. As I said, show some examples!

 

 

0 Kudos
Message 9 of 26
(21,516 Views)

A:Is this discussion related to your recent idea?

V:not really.

-----------

V: at first, it is related normal language. 

at second, it would be easy to use

A:What is "it"? What is "normal"? What is "easy"? Why?

V: it is LabVIEW

 normal language - Java, C++, C#

easy - because easy to use

why - because LabVIEW system would be simpler

-----------

A. If you think you have a magnificient idea, you need to be able to communicate. As I said, show some examples!

V. this is style which is not example of program.

That is not madnificient idea ... I would said it is very primitive idea.

I also can say that LabVIEW developers can communicate also.

I think I wrote really simple suggestions as I could. (English is not my native language Smiley Wink)

If you have any doubt or misundestanding you can communicate write me e-mail I will try to explain better.

0 Kudos
Message 10 of 26
(21,512 Views)