GOTO DWORD statement

Purpose | Transfer program execution to the statement identified by a label or line number.
Syntax | GOTO {label | linenumber} GOTO DWORD dwpointer

Remarks

GOTO causes program flow to jump unconditionally to the code identified by label or linenumber. The label or linenumber must be local to the Sub, Function, Method, or Property where the GOTO statement is located. GOTO differs from GOSUB and other similar control statements, in that after execution of a GOTO, the program retains no memory of where it was before it executed the jump.

Labels and line numbers are private. You cannot GOTO a label outside of the current procedure.

DWORD | GOTO DWORD causes execution to jump unconditionally to address stored in dwpointer. dwpointer must be a Double word, Long integer, or pointer variable that contains the address of a label which is local to the procedure where the GOTO DWORD statement is located.
See also | CALL, CALL DWORD, DO/LOOP, EXIT, FOR/NEXT, FUNCTION, GOSUB, IF block, METHOD, PROPERTY, RETURN, SELECT, SUB, WHILE/WEND

Example

FUNCTION test() AS LONG

RESET X

Start: ' define a label

INCR X ' increment X

IF X < 10 THEN DoBeep

EXIT FUNCTION

.[statements]

DoBeep:

BEEP

GOTO Start ' jump back to Start

END FUNCTION

One method of obtaining the same results without use of GOTO is:

FUNCTION test() AS LONG

FOR X = 1 TO 9

GOSUB DoBeep

NEXT X

EXIT FUNCTION

[statements]

DoBeep:

BEEP

RETURN

END FUNCTION