• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Using arrays

Hey all,

What I want to do is (I thought) really simple.. I want to have a simple scene with some textboxes and when the textboxs are edited, values in the array are changed to the value entered into the scene.
So I have 5 textboxes. In the first, when the text is changed I have it do array push to %ArrayName in position 1 with the value %new_val. This is then repeated in the other textboxes with the only change being the position.

However when I run this (changing only textbox1 for now), I check the array values in the var tab, I see heaps of values for the array. Say I entered Bird in the first box, it seems to be setting %ArrayName1 to Bird (as expected) but then %ArrayName2 has been set to Bir.. %ArrayName3 is Bi, %ArrayName4 is B %ArrayName5 if First and %ArrayName6 is also First.

Why is it doing this and how do I make it only alter the array value corresponding to the correct position?
 
I think I have figured it out, in case anyone else is having this problem I thought I should post.
It is because I had the textbox updating the array every time the text is changed (so for every character addition), this was filling the array and then making a new entry as I had nothing to delete the ones building up. I solved it by adding an array pop command before the array fill one!
 
Back
Top Bottom