Updated: 10/19/2021, 9:29:48 PM
Created: 10/19/2021, 9:29:48 PM
Last Updated By: Kevin Munoz
Read Time: 1 minute(s)
Tags: program control program execution
The GOTO statement causes program execution to jump to the code at a specified label.
Where label refers to an existing location within the current source code.
The location must be the same name as the label.
Labels can be numeric or alphanumeric but alphanumeric labels must be terminated with a colon. Numeric labels can be terminated with a colon but it is not mandatory. The use of the colon in the GOTO statement is optional.
Using the GOTO command obscures the readability of the code and may be a hindrance to maintainability. All programs written using the GOTO construct can be written using structured statements such as LOOP and FOR. There are various opinions on this issue but the consensus is, avoid GOTO.
One possibly acceptable use of the GOTO statement is to transfer execution to an error handler upon detection of a fatal error that will cause the program to terminate as follows:
GOTO Exception;* jump to the exception handler ..... Exception:* exception handler .... STOP
Go back to jBASE BASIC
Go back to Programmers' Reference Guide