From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I build an array using two numeric controls and a button? Whenever I press the button a column of 2 rows (the numeric controls) should be created.

Solved!
Go to solution

I tried many ways so far. 

I know that I can use build array to create an array from two numbers but Im not able to create a 2d array that way

I also tried using Replace array subset but still it wont work.

I know that I have to use an array function that has column index starting at 0 so whenever I press the button the column index incriments by 1 so the next column will change but Im not able to create this.

0 Kudos
Message 1 of 20
(3,323 Views)

You want it to add to your current array? Here's a good way using an event structure:

 

event structure array builder.png

 

edit: Attached the VI for OP

Message 2 of 20
(3,321 Views)

Here's a screenshot to explain myself better.

In this case however, whever In press the button the first column is replaced. 

I want to change the next column whenever I press "next point".

0 Kudos
Message 3 of 20
(3,316 Views)

Download the VI attached to my previous post and try it out! I think it does what you want.

0 Kudos
Message 4 of 20
(3,310 Views)

Greatly appreciated 🙂

0 Kudos
Message 5 of 20
(3,302 Views)

No problem! You may want to mark my first post as the solution instead, for future generation's benefit 😄

0 Kudos
Message 6 of 20
(3,296 Views)

@ijustlovemath wrote:

You want it to add to your current array? Here's a good way using an event structure:


  • I don't understand the purpose of the timeout case. All it does burn CPU cyclces as fast as the computer allows, constantly writing the same stuff to the array indicator. remove it.
  • If you would wire the array indicator before the event structure, it would reset correctly at the beginning of the program. Now you can even use the same event for stop and add, because nothing gets appended to the indicator when you stop. Only one event case needed overall, simplifying the code.
  • It would be much simpler and efficient to add rows instead of columns. Adding columns is expensive in terms of memory management.
  • If the final array size were known, things could be made significanttly more efficient.
Message 9 of 20
(3,277 Views)
Solution
Accepted by topic author patomated

You're the authority on this one Altenbach! Writing this one, I just made it to have it work. Didn't really consider all of that. Here's a modified version for the OP to use should he like:

 

event structure array builder.png

 

 

Message 10 of 20
(3,261 Views)