Avisaro Online Documentation - Wiki
Impressum Kontakt Sitemap

GOSUB ... RETURN

Description

GOSUB is the standard BASIC statement to call subroutines. Subroutines are parts of the program, that can be called to perform specific tasks. The GOSUB statement must be followed by a label name, which refers to the beginning of the subroutine. All subroutines must begin with a label and must have at least one RETURN statement. RETURN causes the subroutine to exit and program flow continues right after the GOSUB call.

Example

The following program prints twice the string "hello from subroutine".

outmode -2
print "hello from main program"
gosub sub
print "hello again"
gosub sub
end

sub:
print "hello from subroutine"
return

Remarks

Subroutines can be nested, that means, subroutines can call other subroutines.