for a while i thought GOTO was awesome, i was told otherwise many times but no-one would tell me what to replace it with.
I decided I'd share with you why not to use it because i thought it was awesome untill i stopped using GOTO's and my code went from this
to this
perfectly organised dish of food
ok that metaphor is probably lame but anyway its tidy code now
there are 2 alternatives that i know of
GOSUB - goes to a chosen label and returns to where it was called when it reads the return command
sync on : sync rate 60
`stuff
GOSUB Main
End
Main:
Do
print "hello world"
Exit
Loop
Return
in that example it skips the end of the program and goes to the loop then returns and ends program
Functions - My personal favourite alternative instead of this
`stuff
Goto Menu
Main:
Do
`stuff
Loop
Menu:
`Load Menu
Goto Main
Its much tidier to put
`stuff
Load_Menu()
Do
`stuff
Loop
Function Load_Menu()
`load menu
Endfunction
I hope this helps understand why people tell you not to use Goto's because to me it makes coding hell, But you may think "how will i ever find the function with all those lines of code?" simple! go to the functions tab on the right hand side of the screen and click the function you want to go to because it has a list of all declared functions.