I thought I understood how For Each worked, but apparently not and I've been stuck on this one all day long.
Hard to explain so I'm attaching an image. This is the exact code as it runs in my program (not the original code, but in my frustration I've had to hack it down to this, to try to work out what's going on).
<img src="http://www.soccerstar.org.uk/foreachimage.png" border="0" />
The text boxes show two different values. There is nothing else in the code, this is exactly how it's set in my program right now. The top text box (outside the for/each loop) shows the correct value that's stored in the tile variable. The one inside the loop shows a different value.
I don't understand what's happening here at all. My understanding of how this SHOULD be working is, it runs through the loop and when the tile with those X/Y/Z coordinates is picked, it will then show that tile's value in the text box, which should of course be exactly the same as the one above.
Presumably I'm doing something wrong, and that 2nd pick isn't picking the same tile?
To add to this, this isn't the original code. In the original code, it doesn't do a 2nd pick of 'ShipTiles' at all, it's attempting to push all of the values in the tiles into an array. So the code inside the loop in the original (which also doesn't work) just says ('Put ShipTiles.Condition into Array.At(X,Y,Z)). It puts the wrong values in. So in that case, it's not doing a 2nd pick of the Shiptiles object, which may be partly what's wrong above.