Misplaced Pages

GOSUB: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editNext edit →Content deleted Content addedVisualWikitext
Revision as of 22:23, 13 July 2011 editGary ml0gmwuuc (talk | contribs)27 editsNo edit summary← Previous edit Revision as of 22:24, 13 July 2011 edit undoGary ml0gmwuuc (talk | contribs)27 editsNo edit summaryNext edit →
Line 1: Line 1:
'''GOSUB''' is a command in many versions of the ] computer ]. GOSUB statements branch to simple kinds of ] without (sometimes with) parameters or local ], the ] command resuming ] from the point at which GOSUB was invoked. The GOSUB command is convenient for performing the same function several times in a BASIC program without duplicating the code.<ref>{{cite web|url=http://www.qbasicnews.com/qboho/qckadvr.gosubr.shtml|title=GOSUB...RETURN Statement Details.|date=1988|accessdate=2008-07-04|author=|publisher=]}}</ref> Using GOSUB too many times, as in a loop, without corresponding RETURN statements would typically cause a ] and when the BASIC interpreter encounters a RETURN statement without a GOSUB it will emit a RETURN WITHOUT GOSUB error. '''GOSUB''' is a command in many versions of the ] computer ]. GOSUB statements branch to simple kinds of ] without (sometimes with) parameters or local ], the ] command resuming ] from the point at which GOSUB was invoked. The GOSUB command is convenient for performing the same function several times in a BASIC program without duplicating the code.<ref>{{cite web|url=http://www.qbasicnews.com/qboho/qckadvr.gosubr.shtml|title=GOSUB...RETURN Statement Details.|date=1988|accessdate=2008-07-04|author=|publisher=]}}</ref> Using GOSUB too many times, as in a loop, without corresponding RETURN statements would typically cause a ] and when the BASIC interpreter encounters a RETURN statement without a GOSUB it will emit a <code>RETURN WITHOUT GOSUB</code> error.


Not all BASIC implementations support GOSUB. For example, in ] it is considered as deprecated in favor of ]/FUNCTION, and is disabled by default.<ref>{{cite web|url=http://www.freebasic.net/wikka.php?wakka=KeyPgGosub|title=GOSUB|date=2008-05-08|accessdate=2008-07-04|author=|publisher=|quote="Gosub support is disabled by default in the -lang fblite unless the Option Gosub statement is used."}}</ref> Not all BASIC implementations support GOSUB. For example, in ] it is considered as deprecated in favor of ]/FUNCTION, and is disabled by default.<ref>{{cite web|url=http://www.freebasic.net/wikka.php?wakka=KeyPgGosub|title=GOSUB|date=2008-05-08|accessdate=2008-07-04|author=|publisher=|quote="Gosub support is disabled by default in the -lang fblite unless the Option Gosub statement is used."}}</ref>

Revision as of 22:24, 13 July 2011

GOSUB is a command in many versions of the BASIC computer programming language. GOSUB statements branch to simple kinds of subroutines without (sometimes with) parameters or local variables, the RETURN command resuming program flow from the point at which GOSUB was invoked. The GOSUB command is convenient for performing the same function several times in a BASIC program without duplicating the code. Using GOSUB too many times, as in a loop, without corresponding RETURN statements would typically cause a stack overflow and when the BASIC interpreter encounters a RETURN statement without a GOSUB it will emit a RETURN WITHOUT GOSUB error.

Not all BASIC implementations support GOSUB. For example, in FreeBASIC it is considered as deprecated in favor of SUB/FUNCTION, and is disabled by default.

Stub icon

This computer-programming-related article is a stub. You can help Misplaced Pages by expanding it.

See also

References

  1. "GOSUB...RETURN Statement Details". Microsoft. 1988. Retrieved 2008-07-04.
  2. "GOSUB". 2008-05-08. Retrieved 2008-07-04. Gosub support is disabled by default in the -lang fblite unless the Option Gosub statement is used.
Stub icon

This programming-language-related article is a stub. You can help Misplaced Pages by expanding it.

Categories: