Labels and Goto

Labels let you name a location in code. Goto jumps to that location. LunarBasic supports labels, but it also checks that jumps stay inside valid scope.

Back to Language Reference


Basic Syntax

<labelName>: Goto <labelName>

Important Rules

What Scope Means

Scope means either the top-level program or the body of the current Function or Sub. Nested blocks such as If, loops, and Select Case branches also affect where a Goto is allowed to jump.

Examples