0 Members and 2 Guests are viewing this topic.
Lbl 0If somethingGoto 1If somethingelseGoto 2Goto 0Lbl 1Do stuffGoto 0Lbl 2Do some other stuffGoto 0
While 10->AIf something1->AIf something else2->AIf A=1Do stuffIf A=2Do some other stuffEnd
0->ALbl TA+1->AIf getKey=0:ThenOutput(1,1,AGoto TEnd
Note that goto's themselves do not slow a game down, only is they are misused. That and the fact that they take a bit of time to execute (since the OS searches your whole program for the Label to jump to) and could make parts of your game slower.Goto can also make your game run slower if they are used incorrectly, try running this programCode: [Select]0->ALbl TA+1->AIf getKey=0:ThenOutput(1,1,AGoto TEndYou will notice as the program counts, the numbers seem to increase slower and slower. This is because you have a Goto inside of an If:Then block. When the calculator enters the If:Then block, it sets aside a bit or memory so that it knows what to do when it gets to the End that closes the block. However, you Goto out of this block and up into T. The TiOS doesn't realize this, and so it still has that chunk of memory set aside. Enter the If Block again and another chunk of memory is set aside. Do this enough and eventually your program gets the dreaded Error:Memory!
Instead of something like Code: [Select]Lbl 0If somethingGoto 1If somethingelseGoto 2Goto 0Lbl 1Do stuffGoto 0Lbl 2Do some other stuffGoto 0You would use Code: [Select]While 10->AIf something1->AIf something else2->AIf A=1Do stuffIf A=2Do some other stuffEnd