LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

local variable behavior in parallel loops

Ok. I'm almost ashamed to post this question.  I thought i understood, but OBVIOUSLY i don't.

Local Variables in parallel loops. I created a little test vi to show how local variable references and data value references would work better between loops then lLocal variables.  I believed that reading a local variable multiple times in a second loop only updated the cnt local variable once per loop cycle.

Attached is a png of my little loops.  I fully expected indicators cnt 2 and cnt 3 to display the same value... but they don't.  The other loops displayed exactly as I expected.

So, please restore my faith.

0 Kudos
Message 1 of 3
(2,621 Views)

Please attach the actual VI, snippets mutilate your code.

 

What is a "local variable reference"?

0 Kudos
Message 2 of 3
(2,596 Views)

@David-n-MO wrote:

I created a little test vi to show how local variable references and data value references would work better between loops then lLocal variables.


define "better". Functionally, value properties and local variables act identically on the surface (under the surface, value property nodes are less efficient, because they execute synchronously and thus cause significantly more overhead. For that reason, local variable are preferred if you have to chose). 


@David-n-MO wrote:

I believed that reading a local variable multiple times in a second loop only updated the cnt local variable once per loop cycle.


Reading a local variable does not update anything. It simply gets the current value of the associated control whenever it is read (there are some details that have to do with the asynchronous update of FP controls. In fact a local variable reads the transfer buffer of the control/indicator, which is sometimes more current).


@David-n-MO wrote:

I fully expected indicators cnt 2 and cnt 3 to display the same value... but they don't.


Wh should they? You read from two different local variables, right? You always get the current control value at the time of the read. They would only be the same if you read once from a local variable and then branch the wire to the two indicators. A local variable can never stand alone, it always points to a control or indicator.

 

 

0 Kudos
Message 3 of 3
(2,579 Views)