LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to declare array size in a labview sub-vi

Solved!
Go to solution

Greetings,

 

I originally posted this question in the CVI forum, but was informed I might have better luck here.

 

First off I must say that I am new to the board and new to labview. I have spent over an hour searching for the answer to my question and have come up empty handed.

 

I have written a "test" as a sub-vi in LV, which will be one of many "tests" called by a test executive which my partner is writing in CVI. He has compiled my sub-vi into a dll, and it runs properly and without errors when all of the inputs are hard-coded as constants inside my sub-vi. Our next step is to have him pass me these same constants through his test executive...but.

 

I have all of the inputs to my sub-vi bundled into a cluster, some of which are arrays of singles. The problem is that when my partner compiles this into a dll, these arrays only have one member ( ex: MyArrayName[1]). What I want to do in LV is the equivalent of declaring my input array size like "Single MyArrayName[100];" in C, but I do not know how to do this.

 

Any help would be greatly appreciated.

 

Thanks for your time folks.

0 Kudos
Message 1 of 8
(15,228 Views)

Arrays are not declared.  Array size is adjusted dynamically.  Simply put the amount of data that you want into an array.  You may use the Initialize Array function.

0 Kudos
Message 2 of 8
(15,220 Views)

Is this what you are looking for?

 

InitArray.png

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
Message 3 of 8
(15,199 Views)
Solution
Accepted by topic author SubstituteHallMonitor

Hi, I posted some answer and documentation in the CVI forum here: hope it may help you.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 8
(15,180 Views)

Hi Substitute, 

 

Pcardinale was correct in that arrays dynamically adjust themselves to fit the amount of data points that are input into them. If you want to pan through the arrays, to view a specific number (such as, if you want to see the 8th element on an array of 10), then you just go to your front panel and the first (0) value should be displayed as a number to the right of a scroll bar. Simply scroll up or down by clicking and the index number will change from 0-9 and reflect the value (on the right) of the element. I have created an example Vi in which I created 2 clusters of 2 arrays. You can pan through the clusters to see the values of the arrays and then pan through the arrays to see the values at each index. If you view the block diagram, I have created my arrays using a random number generator and a for-loop. Because I have generated a set number of points, creating an indicator from the for-loop automatically creates an array. 

 

Please post back if you have anymore questions! I have saved the Vi in 2009 format in case you have an earlier version. 

Jackie

 

 

DAQ Product Marketing Engineer
National Instruments
0 Kudos
Message 5 of 8
(15,143 Views)

Thanks much Mr. B.. Your help along with that of Kraken in the other thread exactly answered what I was looking for. It's great to know that this forum exists so that the Uber-Geeks can help us Knoobs out.

 

Thanks again,

SHM 

0 Kudos
Message 6 of 8
(15,115 Views)

I know this is old but this is how I do it. to initialize to 0:

I extend the array until i get one that is faded. Copy it and then replace the content of the array with the faded element.

Untitled.png

 

For specific size you extend and write giberish to the index you want it initialized and they all unfade.

0 Kudos
Message 7 of 8
(11,735 Views)

@Foreshadow20 wrote:

I know this is old but this is how I do it. to initialize to 0:

I extend the array until i get one that is faded. Copy it and then replace the content of the array with the faded element.

Untitled.png

 

For specific size you extend and write giberish to the index you want it initialized and they all unfade.


No, that's probably not the right way to do it!

 

A "faded element" is nothing special. To make an array diagram constant empty, just drag any element out and back in. The new array will be empty. Typically controls get the data from the user or subVI connector, so clearing it is typically not needed. There is an option to clear indicators when called, No code needed for that. either. There is also "right-click...data operation..empty array).

 

Typically writing gibberish creates an array containing gibberish, so why would anyone want to do that?

This thread is about "fixed sized arrays" and LabVIEW does ot have that datatype (except for LabVIEW FPGA). An array can be initialized at a fixed size and can be kept that way by usng only in-place operations. That is typically sufficient.

 

 

0 Kudos
Message 8 of 8
(11,705 Views)