Control flow statement to jump to another part of the program

Goto label

Jumps code execution to a line label.

When using Goto label to exit a scope, any local variables defined in that scope are destroyed (destructors are called).

Usage of Goto label may be disallowed when it skips a variable definition but not the end of the variable's scope. If the variable requires construction, a compiler error is shown. For other variables, a compiler warning is shown. This is intended to prevent potential accesses to uninitialized variables, and ensures that automatic destruction never happens to an uninitialized variable.

For better source code readability, overuse of Goto should be avoided in favor of more modern structures such as Do...Loop, For...Next, Sub, and Function.

    Goto there


    Print "Welcome!"
    Goto backagain

'' Compile with -lang qb or fblite

'$lang: "qb"

1 Goto 3
2 End
3 Print "Welcome!"
4 Goto 2

Dialect Differences:
Differences from QB:
See also:
Back to Control Flow
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode