LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to append array elements without overwriting?

Solved!
Go to solution

probably a repeated question, can anyone tell how to append a new element to an array to the next location without deleting the previous one?

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 1 of 12
(67,974 Views)
Solution
Accepted by LV_Enthu

Use the build array and wire the old array to the first position and the new value to the next position. This will append while leaving the old array as is.

Message 2 of 12
(67,972 Views)

you mean somethin like this?

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 3 of 12
(67,964 Views)

You can also use the Insert Into Array function with the index input left unwired.  The speed might vary between the two depending on the type of data you're dealing with.

 

If you know the size of the array you'll end up with ahead of time, then I believe the fastest way to do it is to initialize the array ahead of time and then replace array elements.  You can use the index terminal of a loop to select the spot to replace.  For a simple application the complexity of doing this probably doesn't justify the speed increase.

 

Edit:  Your example above will work.  You could have tested the code faster than you took a screenshot and posted it.

0 Kudos
Message 4 of 12
(67,962 Views)

yeah, that actually worked, i did not test it properly, this is actually what i wanted, adding element only when i want to add..

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 5 of 12
(67,952 Views)

Or something like this will work.

 

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
Message 6 of 12
(67,949 Views)

Your solution is more along the lines of what SunshineDesign proposed.  But that will work.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 7 of 12
(67,945 Views)

yeah, i accidently marked the wrong post as CORRECT answer, i would like to change it to the correct post if some1 needs to refer in future

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 8 of 12
(67,938 Views)

Yea, I'm not sure how to do that.  You might have to get with the moderator.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 9 of 12
(67,934 Views)

If you are the OP, you can go to the option pull-down on the solution message and choose to remove it as the accepted solution then mark another reply.

0 Kudos
Message 10 of 12
(67,920 Views)