An example of the goto statement is shown below:
var a:10;
main
// Here is a label statement
top:
// do something
a++;
// Here are some goto statements
if(a == 10)
goto bottom;
else
goto top;
endif
// Here is another label
bottom:
endmain
Note that it is illegal to try to jump to a label defined in a different function:
main
f();
end
func f()
// Here is the label
mylabel:
g();
endfunc
func g()
// This is illegal!
goto mylabel;
end
It is possible however to jump from a function to a label in the main..endmain section using the jump_statement.