line number is the first line number of the subroutine.
A subroutine may be called any number of times in a program, and a subroutine may be called from within another subroutine. Such nesting of subroutines is limited only by available memory.
A RETURN statement in a subroutine causes GW-BASIC to return to the statement following the most recent GOSUB statement. A subroutine can contain more than one RETURN statement, should logic dictate a RETURN at different points in the subroutine.
Subroutines can appear anywhere in the program, but must be readily distinguishable from the main program.
To prevent inadvertent entry, precede the subroutine by a STOP, END, or GOTO statement to direct program control around the subroutine.
10 GOSUB 40
20 PRINT "BACK FROM SUBROUTINE"
40 PRINT "SUBROUTINE";
50 PRINT " IN";
60 PRINT " PROGRESS"
SUBROUTINE IN PROGRESS
BACK FROM SUBROUTINE
The END statement in line 30 prevents re-execution of the subroutine.
All Frank Sinatra recordings, All Beatles albums, All solo albums from John Lennon, Paul McCartney, George Harrison and Ringo Starr, All Beatles songs, List of Platinum selling albums, Database with hits from 1950 to 1999.
Sought after DLL files, Nutworks magazine (retro), Worldwide ISO and TLD codes, File extensions database, The Hackers dictionary, Free software for the Atari, Amiga and Macintosh, Nokia smartphone, PocketPC, List of all BASIC programming language commands, List of all DOS commands, Free Advanced Bash-Scripting Guide (Linux-Unix)