COMMODORE PLUS/4 WORLD
  Home  Search  Games  Tapes  Covers  Cheats  Maps  Software  New Stuff 
 Hall Of Fame  Game Endings  Features  Solutions  Remakes  Publications  Magazines  Effects  Top List 
 Members  Groups  Plus/4 Encyclopedia  Hardware  Tools  Options  Forum 
Login
Plus/4 EncyclopediaFirstBackNextLast

GOSUB Statement
Category
Reference/Commodore Basic V3.5

Topic
GOSUB line#

AKA GO to SUBroutine. This is similar to the GOTO statement, but remembers where it was executed from. When a RETURN statement is encountered, the program resumes execution following the last encountered GOSUB statement.

This is normally used for accessing sections of a program (subroutine) that are kept isolated from the main program.

Multiple GOSUBs may be executed concurrently. A RETURN statement returns to the last executed GOSUB statement, therefore multiple RETURN statements will be required to end all GOSUB statements.

If a RETURN statement is encountered and there is no GOSUB in operation, a ?RETURN WITHOUT GOSUB ERROR will occur.

If a line number is not specified after a GOSUB statement, it assumes line 0. If the specified line number does not exist in the program, an ?UNDEF''D STATEMENT ERROR occurs.

Examples
20 GOSUB 300 Goes to line 300 and executes the program from there
:
:

300 PRINT "HELLO" : RETURN The RETURN statement returns program execution to the point immediately following the GOSUB statement

Abbreviation
GO SHIFT+S



Copyright © Plus/4 World Team, 2001-2013