LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using arrays with sub vi's

Solved!
Go to solution

Hi!

I have a question about the correct method for using a sub-VI to update an array of integers. How do I pass the array to the sub-VI, without creating a second array for the output (or what is returned)?

 

This is for calculating histogram data. Basically, I have a set of input values that are evaluated to determine which bin location (array index) to increment the count on. I would then like to use the same sub-VI to update the array (call it "BinsIn", for discussion sake) and return to the main VI. Thinking in text-based programming terms I want to pass the array by reference, so I'm not wasting resources.

I've read some posts that discuss using Ctl Refnum, but I'm not sure if this is what I want to do...

 

Any help would be appreciated.

Thanks,

Shaun

BR;
Shaun
0 Kudos
Message 1 of 4
(2,266 Views)
Solution
Accepted by topic author SLD

Don't think in text-based languages.  There's no difference passing by reference versus by value.  If the compiler determines that the input array can be reused as the output array then it will do so.  You can give it some hints that it should do this by writing your code to do operations "in-place" (search for that term on this forum) and avoiding functions that may require copying the array such as delete from array.  Best thing to do is probably write your code so that it works, then upload it here so that other contributors can comment and help make it more efficient.

Message 2 of 4
(2,259 Views)

:Good advice from nathand-  also.  search histogram and author Christian Altenbach (user name Altenbach)  He's posted some pretty effecient histogram algorhythms around somewhere smileywink:


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 4
(2,249 Views)

Thanks for the info & advice. Almost seems too simple in some ways...

BR;
Shaun
Message 4 of 4
(2,230 Views)