Not Calculating Correctly (0 + 7 = 8?)

I’m having trouble with… a subroutine.

This is what’s on my startup page:
image

The part of the subroutine I’m struggling with is:
image

This is the code I’m testing it with and what it’s producing:

Are you sure that you’re displaying assignments_done there and not main_assignments_done

Yes, because it’s calculating it from this line:
*set math (assignments_done - old_assignments_done)

Just to be on the safe side: did you check the assignments_done was 0 before running that subroutine?

Could you try printing assignments_done and old_assignments_done out separately there?

Nothing looks wrong at first glance, so at this point its just trying to figure out exactly where the problem is.

For example, if assignments_done shows as being 8, then you know thats what you can ctrl+F to search for. If old_assignments_done is -1, you can look for errors there instead.

1 Like

I’m still at a loss. When I print both out before running the calculations they both say they’re set to 0 like they should be.

I knew it was because I’m just testing the functionality. But I printed it out to be sure, and it definitely is.

Can you show the whole subroutine?

uhhh it’s like 2K lines, so I was trying to simplify it down to just the assignments in their own function and that worked. I think I have somewhere to at least start debugging now. Thank you!

I’m asking, because the main_assignments_done part seems to be working correctly, and it’s using the exactly same math unless I’m mistaken, so I think it’s possible that you’re accidentally setting the variables somewhere else. I’d recommend being on lookout for that.

1 Like

In the middle of the subroutine I have a check for one of the assignments that if the check passed, it’d add one to assignments_done but not main_assignments_done, but the check should be failing. I’m going to work around that area and see if I can’t fix it that way.

It looks like you’re using CSIDE? This is where step through debugging or variable tracking will be very helpful. Details on both can be found in the docs!

1 Like

Gonna be honest. I fixed it but I still have no clue how or what was causing the issue to begin with. I tested the part I thought might be causing it, but it wasn’t that. I’ll definitely look more into the docs, though. Thank you!

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.