GoTo Statement
The GoTo instruction causes program control to branch unconditionally to a designated statement label.
Syntax
GoTo { label }
Parameters
- label
- Program execution will jump to the line on which the label resides. The label can be up to 32 characters. However, the first character must be an alphabetic character (not numeric).
Description
The GoTo instruction causes program control to branch to the user specified label. The program then executes the statement on that line and continues execution from that line on. GoTo is most commonly used for jumping to an exit label because of an error.
Note
Using Too Many GoTo's
Please be careful with the GoTo instruction since using too many GoTo's in a program can make the program difficult to understand. The general rule is to try to use as few GoTo instructions as possible. Some GoTo's are almost always necessary. However, jumping all over the source code through using too many GoTo statements is an easy way to cause problems.
See Also
GoSub, OnErr
GoTo Statement Example
The following example shows a simple function which uses a GoTo instruction to branch to a line label.
Function main
If Sw(1) = Off Then
GoTo mainAbort
EndIf
Print "Input 1 was On, continuing cycle"
.
.
Exit Function
mainAbort:
Print "Input 1 was OFF, cycle aborted!"
Fend