Page 1 of 1

How do I find my corresponding array entry?

PostPosted: Sat Dec 27, 2014 10:50 pm
by facecrime
Hi,
I have a 2D array that contains a list of UIDs in row 1 and a flag in row2
I pick a random line, do stuff with the UID and delete the line
and then I want to find that other line that has the same flag to remove it as well

could look something like this:

UID Flag
41 0
45 0
50 1 <- randomizer might pick this line for example
53 1
59 2
62 2

how do i find and remove the other ones that are flagged the same?

Re: How do I find my corresponding array entry?

PostPosted: Sat Dec 27, 2014 10:51 pm
by facecrime
my approach was to go:

array>for each X element
compare: value at (loopindex,1) = pickedFlag
action: delete row (loopindex) from X axis

but I doesn't seem to work

Re: How do I find my corresponding array entry?

PostPosted: Sat Dec 27, 2014 11:23 pm
by codah
Try

System: For "" from Array.Width - 1 to 0
Array: Value at (loopindex, 1) = pickedFlag ---> Array: Delete index loopindex from X axis

edit: I rarely use Array: For Each. Maybe it's just personal preference.
Also I'm not sure what you meant by "action : delete row (loopindex)". You never wanted to delete a row, just a column. Remember C2 debugger shows the axes switched 90 degrees, so rows look like columns and vice-versa. I'm going backwards in the above code because if you modify the array you're currently iterating, you'll skip a column when the array gets shorter by 1 column.

Re: How do I find my corresponding array entry?

PostPosted: Sat Dec 27, 2014 11:48 pm
by facecrime
guess we're talking about the same thing, what i want to delete is the line with the picked UID and its flag.
thanks for elaborating, wasn't sure you meant what i thought you meant :P seems to be working now, thanks!

Re: How do I find my corresponding array entry?

PostPosted: Sat Dec 27, 2014 11:54 pm
by codah
facecrime wrote:guess we're talking about the same thing, what i want to delete is the line with the picked UID and its flag.
thanks for elaborating, wasn't sure you meant what i thought you meant :P seems to be working now, thanks!


Glad it helped. I was just trying to say that you're deleting columns, not rows (lines) :)

Your array actually looks like this:

Code: Select all
41, 45, 50, 53, 59, 62
0,  0,  1,  1,  2,  2