01-11-2012 04:23 PM
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?
Solved! Go to Solution.
01-11-2012 04:27 PM
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.
01-11-2012 04:39 PM - edited 01-11-2012 04:41 PM
you mean somethin like this?
01-11-2012 04:44 PM - edited 01-11-2012 04:46 PM
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.
01-11-2012 04:53 PM
yeah, that actually worked, i did not test it properly, this is actually what i wanted, adding element only when i want to add..
01-11-2012 04:54 PM
Or something like this will work.
01-11-2012 04:56 PM - edited 01-11-2012 04:57 PM
Your solution is more along the lines of what SunshineDesign proposed. But that will work.
01-11-2012 04:59 PM
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
01-11-2012 05:02 PM
Yea, I'm not sure how to do that. You might have to get with the moderator.
01-11-2012 06:16 PM
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.