GOTO Statement

Jumps to a statement label.

# Syntax

GOTO label

Part | Type | Description
--- | --- | ---
label | String | Label to which to jump.

# Note

The GOTO statement is included in REALbasic only for compatibility with other implementations of BASIC. Historically, GOTO was used extensively in unstructured BASIC to manage flow-of-control. At that time, a program consisted of a single master code segment, with flow-of-control managed by numerous GOTO statements that jumped execution around from one section of code to another. In time, such programs proved very hard to maintain because the underlying logic of the program was difficult to follow--especially after the original programmer left the project. The inability to maintain unstructured programs led to the development of event-driven, object-oriented programming environments such as REALbasic.

# Example

The following example displays a warning message if Checkbox1 is checked.

If checkbox1.value then
GOTO myCode
End If
//Return used to keep RB from executing the labelled statement anyway
Return
myCode: //label to jump to
MsgBox "Unstructured programming is bad"

In place of all this, it is recommended that you use:

If Not CheckBox1.Value then Return

# See Also

Exit, Return statements.