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 or Function 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 Sub or Function. |
DWORD |
GOTO DWORD causes execution to jump unconditionally
to address stored in dwpointer. dwpointer must be
a Double
word, Long integer, or
|
See also |
CALL, CALL DWORD, DO/LOOP, EXIT, FOR/NEXT, FUNCTION/END FUNCTION, GOSUB, IF block, RETURN, SELECT, SUB/END 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 ... 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 ... DoBeep: BEEP RETURN END FUNCTION |