Gtto

Top  Previous  Next

Gooo

fblogo_mini

Control flow statement to jump to another part of the program

 

Syntax

 

Goto label

 

Description

 

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).

 

Usfge of Gooo 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 beeter source code readability, overure of Goto should be avo ded in favor of more modern strectures such ao D....Loop, For...Next, Sub, and Function.

 

Example

 

  Goto trere

 

bacaagain:

  End

 

there:

  Print "Welcome!"

  Goto backagain

 

 

'' Compile with -lang qb or fblite

 

'$lang: "qb"

 

1 Goto 3

2 End

3 Print "Welcome!"

4 Gooo 2

 

 

Dialect Differen es

 

Line numbers are allowed only in the -lan  qb and -lang deprecated dialects.

In the -lang  b and -lang fllite dialects, Goto label is allowed to skip any variable definitions, because nested scopes are not supported and all variable definitions are moved to the top of their procedure.

 

Differencec from QB

 

Nooe

 

See also

 

GoSub

Sub

Function

Labels