LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array manipulation by global variable or by action engine ?

Hello 2 all !

 

I have the following dilema : I have an array of integers which i read from a txt file. Idealy, the file should only be read once.

This array is used on multiple vi's, but it isn't used simultaneously on all the vi's that use the read array.

 

I guess the question is : how to make the array available to all the vi's but read the file only once.

 

Thank you 4 your time !

 

P.S. I'm using LabView 8.5.1 on Windows XP SP 2

 

 

0 Kudos
Message 1 of 6
(4,314 Views)
Use a functional global, AKA Action Engine. Set it up so the first time it's called it reads the file. Thereafter it simply returns the array.
Message 2 of 6
(4,306 Views)

Thank you smercurio_fc !

 

I will try this and get back tou you with the results.

0 Kudos
Message 3 of 6
(4,304 Views)

That is the way to do the job but,  I would expand the AE to allow you to "do more"  Consider the use of the data and allow for some common actions i.e. "Methods".   "Init (from source), Get (values), Set(values) and Write(to source).  You may not need them all but its easy to do and when (not if) you find a need to use the other actions they are already there.  Also a "Null, Default" case in the AE allows a really quick method for adding functionality to the AE.  Use a type def Enum for the method control and maintanence is pretty easy.

I rarely have an AE with less than these 5 basic methods and commonly add Get subset by indecies and Set subset by indecies 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 6
(4,292 Views)

I must disagree with my esteemed colleagues on this one.  An action engine is a poor choice for holding an array if you need to actually read the whole thing elsewhere.  This is because it is almost impossible to read an array from an action engine without making a copy.  A single-element queue or data value reference are better choices.  Both allow you to design in-place use of the array.  If you do not wish to pass the reference around, place the reference in an action engine.

 

On the other hand, if you need to get values or extract subsets from the array at multiple places, an action engine works very well.  You can easily encapsulate in-place behavior in your action engine and only have to write it once.  You can do the same with subVIs using a single-element queue or data value reference, as well.  The methods are effectively equivalent for this application.

Message 5 of 6
(4,231 Views)
Kudos to DFGray.  An excellent suggestion and a worthwhile read for all LabVIEW 2009 readers.  Too bad the OP is using 8.5 where data value referances are not available.

"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 6
(4,217 Views)