NAME

goto - branch to a specified line

SYNOPSIS

goto LineNum
goto LineLab

DESCRIPTION

Goto is used to branch to a specified line in the module.  The line number LineNum or line label LineLab specifies the line to which control is transferred.  Execution continues with the first executable statement at or beyond the specified line. 

A branch may not cause control to be transferred into or out of a subprogram or user defined function.  In order to branch to different lines depending on the value of an expression, use the on goto statement. 

EXAMPLE

The program
	for i = 1 to 5
		print i
	next
could be written as
	      i = 1
	loop: if i > 5 then end
	      print i
	      i = i + 1
	      goto loop
Both produce the output
	 1
	 2
	 3
	 4
	 5
The first program is preferable because constructs such as for...next are inherently clearer than equivalent code using goto branches. 

SEE ALSO

gosub, on gosub, on goto

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber