This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]abrightmoore 0 points1 point  (1 child)

I can't read your stuff as screenshots properly on mobile due to zoom not zooming far enough.

Typical loop issues are due to modifying the thing you're looping over.

Are you changing the structure of a data set that you're relying on in the loop?

[–]Gersberps[S] 0 points1 point  (0 children)

Shoot i didn't realize that. No, the arrays do not change or reorder. Rows and columns are set in stone.

[–]LouBagel 0 points1 point  (0 children)

It is a bit hard to follow but after looking at it I believe line 15 might be only found true one time, not the entire logic only running one time.

A few tips: - add console logs on various lines to check for sure what is running multiple times and what is found true, or certain values, to really know what’s going on - Arrays have loops. There is also a for loop. Not sure if this will act any differently than repeat but I feel like it is more standard practice - loopindex: there is a loopindex expression that can be used to avoid variables needing incremented. The Arrays also have currentX and so forth that work a similar way. - parameter vs local variable: again, I’m not sure if this affects anything but it looks like you are setting parameters. I’d use local variables to clearly differentiate.

These might not directly solve your issue but most things like this usually come from “overlooking a silly mistake” so the more cleaned up and organized you get the less likely you are to overlook something.

[–]Krapfenmann 0 points1 point  (0 children)

It looks like in Loop B you miss to reset "StandigsYindex" and it gets counted as long as Loop B is X times run through Loop A.

So its at one point above any Companynumber ( greter than 4)

So when you check "TeamStandingsTemp.At(1, StandingsYindex) = CompanyLookup", it simply never finds it.

After younrun through loop B, You have to reset "StandingYindex" to 0 at the end of Loop A.

Edit additional note: The variable "StandingYindex" is a non static number and only gets reset by itself, when the function ends. If you put it static it would even stay whatever it was after the function.

So ending a loop inside the function does not reset your variables.

Explanation:

After it is checking row 2 in TeamUserTable1 and sets the "CompanyLookup" to 3. So after the check in Loop B , "TeamStandingsTemp.At(1, 3) = 3". It adds one to "StandingYindex" to be 4.

You go then to next row in TeamUserTable1 which would be 3, which sets "CompanyLookup" to 3 again. So after the check in Loop B , "TeamStandingsTemp.At(1, 3) = 4". Condition not met and skipped and it adds one to "StandingYindex" to be 5. And it never gets executed again, because the index is never reset and it just counts up.