Label problems

BlitzMax Forums/BlitzMax Beginners Area/Label problems

Grey Alien(Posted 2006) [#1]
I have a label in my game and I want to do a goto. When I compile I get "Compile Error, Labels must appear before a loop or DefData statement", yet the example for "Goto" (in the docs) compiles fine. What is going on?

Thanks


CS_TBL(Posted 2006) [#2]
Wasn't there a label restriction @ strict mode orso?


VP(Posted 2006) [#3]
I'm sure I read that Strict disables Goto as well.

There must be a better way than using a Goto?


Grey Alien(Posted 2006) [#4]
yeah there probably is, I was feeling lazy. OK so it's cos I've got strict on, thanks.


Dreamora(Posted 2006) [#5]
GoTo is slugish programming thus disabled in Strict.

If you needed it to exit nested loops, you can label the loops and exit several nested loops by exit labelname as well as continue labelname


FlameDuck(Posted 2006) [#6]
It's not slugish programming. It just has the potential to mess with scope and screw up the state of the stack, causing random crashes and making it near impossible to maintain code. Good for job security tho'.


Grey Alien(Posted 2006) [#7]
Goto wasn't sluggish when the Spectrum was invented, anyway ... it was just the one thing, Goto Shutdown, called in my main loop so that the shutdown proc could be run. I just made it into a function in the end, so no worries. Actually, some people even decry the use of Return to exit prematurely from functions, thinking everything should be indented/nested hugely even if it actually makes the code harder to understand...


FlameDuck(Posted 2006) [#8]
Goto wasn't sluggish when the Spectrum was invented
Compilers wheren't as advanced, memory wasn't as abundant, and programs wheren't as complex at the time.

Actually, some people even decry the use of Return to exit prematurely from functions
Yeah. Well there's no way to guard against that kind of stupidity.


Xerra(Posted 2006) [#9]
Goto is a relic from the days when source code still had line numbers. And I'm old enough to still remember that :)