| Return Statement |
Syntax
GoSub label ... label Return
label
Use: Required
A subroutine label within a procedure.
Description
Branches back to a calling GoSub statement after executing a subroutine within a procedure.
Rules at a Glance
A subroutine can include an number of Return statements.
Return branches back to the statement immediately following the last executed GoSub statement in the current subroutine.
A GoSub statement and the subroutine it calls must reside within the same procedure.
Programming Tips and Gotchas
The Return statement is only included in this book for completeness, should you have to maintain legacy code; otherwise, you shouldn't be writing new code using the GoSub...Return statements, since it tends to create "spaghetti" code that is very difficult to read and to maintain. Code should be rewritten using separate procedures.
See Also
- GoSub Statement
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access