King Harold wrote:"If" does not go with "End"
"If" "Then" goes with "End"
"If" is just used on its own and it will skip the NEXT like when FALSE, "If" "Then" will skip everything until the next "End" when FALSE. If the condition is true then they do nothing except take time. (TRUE being 1 or greater)
Also, those "End"s you have will never be executed since you "Goto" before the parser gets to them. "Goto"s are relatively slow and unreachable code is not very useful.
So, to fix your code, add a "Then" after every "If" ("Then" can be found right between "If" and "Else")
Or better yet:
Code: Select all
1->A
1->B
repeat 0
repeat Ans
getKey
End
Ans->K
Output(A,B," %that is 1 space, and this is a comment
B+(K=26)(B<16)-(K=24)(B>1)->B
A+(K=34)(A<8)-(K=25)(A>1)->A
Output(A,B,"?
End
Untested but should work ('work' being defined as "moves a question mark around the screen using the arrow keys")
Lesson learned: conditionals build into functions are faster than If/Then statements.
PS: the number of IF statements allowed is unlimited except by the size of the RAM.
I just wanted to show that this is actually simple when you think about TI's parser. Let's examine this line:
B+(K=26)(B<16)-(K=24)(B>1)->B
Why does this work?? Well let's look at it. TI will parse this and "simplify" it to true and false(1 and 0 respectivly). So let's say K = 26 and B = 1. Well then it would turn into this.
B+(1)(1)-(0)(0)->B
which is B+(1*1)-(0*0)->B which I think you should understand. Well let's say it would be.
B+2(K=26)(B<16)-2(K=24)(B>1)->B then that turns into B+2*(1*1)-2*(0*0)->B
It is a very ingenious trick for whoever thought it up. This line could also be optimized for size though too. It will stay the same speed though. Here's the benchmarks.
B+(K=26)(B<16)-(K=24)(B>1)->B
Bytes: 37
200 repeats: 3 seconds
1000 repeats: 12 seconds
B+(K=26 and B<16)-(K=24 and B>1->B
Bytes: 34
200 repeats: 3 seconds
1000 repeats: 12 seconds