Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: meishe91 on November 11, 2010, 12:50:19 am

Title: For( Loop Slowdown Update
Post by: meishe91 on November 11, 2010, 12:50:19 am
Most of us know about the For( slow down issues. If you don't, I'll explain it really fast.

Basically if you have a piece of code that does something like this:

Code: [Select]
For(A,1,9
If fPart(A/2
\Do something.\
End

When ever that conditional is false it will cause a slow down for the loop, which is annoying. However there are three ways to fix this. First, you can simply put a parenthesis at the end of the For( loop line (so it'd become For(A,1,9)), second, there is a OS fix by BrandonW that apparently fixes it and, three, you can make the If statement an If:Then statement.

Now to the point of this thread. I know I have been curious about this question for quite a while, as I'm sure a few other people. The question is basically: What about if you have nested For( loops? Do you have to close both of them?

Well to be honest we still don't have a definitive answer to this but the current thinking, by a lot of people is that you only have to close the nested one. So for example:

Code: (Took 44 seconds.) [Select]
For(A,0,94
For(B,0,62
If not(AB
Pxl-On(B,A
End
End

could become:

Code: (Took 37 seconds.) [Select]
For(A,0,94
For(B,0,62)
If not(AB
Pxl-On(B,A
End
End

I just did a quick test with just this example and it seems to have checked out however this hasn't been concretely proven yet. Just thought I'd let everyone know :)

Courtesy of DJ:
Quote
In some rare cases, not closing the parhentesis of a for( loop under such circumnstances can cause the calc to slow down by about 1.5 until the ON key is pressed or the program is exited.
Title: Re: For( Loop Slowdown Update
Post by: DJ Omnimaga on November 11, 2010, 12:56:21 am
Interesting. Could you add that in some rare cases, not closing the parhentesis of a for( loop under such circumnstances can cause the calc to slow down by about 1.5 until the ON key is pressed or the program is exited? I had that happen while coding Illusiat 13, but I don't know how I triggered that.

BrandonW released a patch fixing those For loop issues, but it's good to keep that trick in mind since most people don't have his patch installed.
Title: Re: For( Loop Slowdown Update
Post by: meishe91 on November 11, 2010, 01:00:17 am
I don't know a whole lot about that rare situation you've encountered so I just copied and pasted what you had said :P Thanks.