en:gosub [BASIC 256 - Language Documentation]

# BASIC 256 - Language Documentation

en:gosub

## Gosub (Statement)

### Format

gosub label
label:
statement(s)
return

### Description

Jumps to the specified label. Upon encountering a Return statement the program will continue at the line following the Gosub. Gosubs may call other gosubs but all variables are shared.

### Example

    a$ = "Hello"
    gosub double
    print a$
    b = 3
    gosub triple
    print b
    end
    double:
    a$ = a$ + a$
    return
    triple:
    b = b * 3
    return

will display

    HelloHello
    9

### See Also

Begin Case / Case / End Case, Call, Continue Do, Continue For, Continue While, Do / Until, End, Exit Do, Exit For, Exit While, For / Next, Function, Global, Goto, Gosub, If Then, Pause, Ref, Rem, Return, Subroutine, While / End While

### Notes

As of version 0.9.9.2 Goto, Gosub, and labels can not be used in Function and Subroutine definitions.

en/gosub.txt · Last modified: 2014/02/09 20:43 by admin