BeSly Software Solutions About yab Demos About us Admin


goto -- continue execution at another point within your program (and never come back)

goto foo 


label foo 

The goto-statement passes the flow of execution to another point within your program (which is normally marked with a label).
goto is normally considered obsolete and harmful, however in yab it may be put to the good use of leaving loops (e.g. while or for) prematurely. Note however, that subroutines may not be left with the goto-statement.

//*** requires ncurses support compiled in ***
//See Documentation/Advanced for info.
clear screen
print "Please press any key to continue." 
print "(program will continue by itself within 10 seconds)" 
for a=1 to 10 
	if (inkey$(1)<>"") goto done 
next a 
label done 
print "Hello World!" 

Here the goto-statment is used to leave the for-loop prematurely. Start this program in a terminal.

Related: gosub, on goto