LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

creating an array with dynamic size

Solved!
Go to solution

I'm wondering how to do this in labview.I can't find a tutorial. If user enters a number lets say 7, then press a button then array with size of 7 is created . I tried with loop function but it didnt work

0 Kudos
Message 1 of 5
(4,804 Views)

You can build an array with initialize array.

 

You can track a button press with an Event Structure. 

 

Put a Value Change event for the button on the event structure and place initialize array inside the case.

 

If you want a different initialization process, you can do that instead. 


GCentralI'm attending the GLA Summit!
0 Kudos
Message 2 of 5
(4,784 Views)

This is what I did too but I need to drag the array manual to see it. Is there a way that once you press the button it shows it. Also, currently my array type is an indicator so the value is what I put for initilizing . Is there a way once the user pressed the button, array is created. then user manual enters the values he wants .See the attached file.  So he enters 5 for intervals, then an array of size 5 is created. then he enters 3,6,9,1,2 in the array 

0 Kudos
Message 3 of 5
(4,747 Views)
Solution
Accepted by topic author Canucks.canucks

There is a property for setting the number of elements visible for an array control/indicator.  Right click on your array and create->property node.  I do not remember the exact name, but it will be obvious.

 

And if you want the user to edit the value, it needs to be a control.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 5
(4,733 Views)

@Canucks.canucks wrote:

This is what I did too but I need to drag the array manual to see it. Is there a way that once you press the button it shows it. Also, currently my array type is an indicator so the value is what I put for initilizing . Is there a way once the user pressed the button, array is created. then user manual enters the values he wants .See the attached file.  So he enters 5 for intervals, then an array of size 5 is created. then he enters 3,6,9,1,2 in the array 


You're trying to solve two different problems.

 

1) Create an array of size n

2) Display all values of the array

 

The first you're doing already.  The display doesn't change the data contained in the array.  If you can drag it to see the values, you've made the array.

 

The second, you'll want to take some time to think about before implementing.  crossrulz gave you the answer.  But, you'll want to think about what this CAN do.  If the user hits 5, no big deal.  If they hit 10, probably not a big deal.  What if they hit 100?  Do you want your VI stretching that far?  Often, it's a better decision to choose your max viewable length and let the user see the uninitialized values.  If you do want it to grow, you'll want to determine a max size and add some logic to prevent the array from displaying any more than that number of elements.

0 Kudos
Message 5 of 5
(4,685 Views)