Programmer Guide/Command Reference/GOSUB: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
  GOSUB <var>label</var> [<var>arguments</var>]
  GOSUB <var>subrlabel</var> [<var>arguments</var>]
Call the local subroutine at <var>label</var> label. The call to a subroutine is like starting a macro, but instead of calling a new macro source code, a copy of the calling macro is created and the execution of the copy is started at label. A subroutine must be finished with the [[Programmer_Guide/Command_Reference/EXIT|EXIT]] command (= return).
Call the local subroutine at <var>subrlabel</var> label. Calling a local subroutine is like starting a new macro, but the execution begins at the label subrlabel and not with the first line of the macro code. The subroutine will get an own execution environment and an own local variable space. Use the command [[Programmer_Guide/Command_Reference/EXIT|EXIT]] to end the subroutine and to return a result to the caller.
 
Note: The command [[Programmer Guide/Command Reference/GOSUBX|GOSUBX]] works like this command, but the called subroutine uses the same ''local variable environment'' as the caller.
 
See also:
[[../GOTO|GOTO]], [[../DISPATCH|DISPATCH]], [[../MACRO|MACRO]]

Latest revision as of 09:55, 25 January 2016

GOSUB subrlabel [arguments]

Call the local subroutine at subrlabel label. Calling a local subroutine is like starting a new macro, but the execution begins at the label subrlabel and not with the first line of the macro code. The subroutine will get an own execution environment and an own local variable space. Use the command EXIT to end the subroutine and to return a result to the caller.

Note: The command GOSUBX works like this command, but the called subroutine uses the same local variable environment as the caller.

See also: GOTO, DISPATCH, MACRO

Navigation menu

Personal tools