LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Initializing Shared Variables (Does Labview pass by values or by reference?)

Hi,

 

I have a set of 7 shared variables that are initialized as 1-D arrays with 30 SINGLE elements with a value of 0.  I would like to call the initialize array.vi only once and just wire it to each of the 7 write node vi's for the shared variables.  Each of the arrays will then be populated with various measurement data later in the program.

 

My question is, does LabVIEW pass by reference, or by value when wiring the resulting array to each of the 7 write nodes?  If it passes by reference, each of the 7 variables will all reference the same block of memory.  If it passes by value, 7 different blocks of memory will be created in addition to the original block created by the initialize array vi.

 

If by reference, then I will need to place 7 different initialize vi's.  If by value, then I only need to place it once.

 

Thanks for clarifying,

 

Chris

0 Kudos
Message 1 of 2
(2,966 Views)

Hi geo,

 

just use one InitArray and branch the wire. LabVIEW does all the memory management for you!

 

(General answer : LabVIEW uses DATAFLOW, values are usually sent by wires and passed by value.)

 

If by reference, then I will need to place 7 different initialize vi's.  If by value, then I only need to place it once.

That's irrelevant!

Each SharedVariable maintains it's own memory buffer…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 2
(2,961 Views)