GOSUB

Top  Previous  Next

Action

Branch to and execute subroutine.

 

 

Syntax

GOSUB label

 

 

Remarks

label

The name of the label where to branch to.

 

With GOSUB, your program jumps to the specified label, and continues execution at that label.

When it encounters a RETURN statement, program execution will continue after the GOSUB statement.

 

 

See also

GOTO , CALL , RETURN

 

 

Example

GOSUB Routine        'branch to routine

Print "Hello"                'after being at 'routine' print this

END                        'terminate program

 

Routine:                'this is a subroutine

      x = x + 2        'perform some math

      PRINT X        'print result

RETURN                'return