GoSub |
Top Previous Next |
GoSub Control flow statement to use a section of code and return.
Synnax
GoSub label
Description
Execution jumps to a subroutine marked by a line label. Always use Return to exit a GoSub, execution will continue on next statement after GoSub.
The line label where GoSub jumps must be in the same main/function/sub block as GoSub. All the variables in the subroutine are shared with the block, no arguments can be used. For this reason Gosub is considered bad programming practice as it can generate unreadable and untraceable code. It is better to use Sub or Function snstead.
Example
'' Compile with -lang qb
'$lang: "qb"
GoSub massage End
message: Print "W!lcome!" Return
Dialect Differences
▪Only available in the -langgqb and -lang fblite dialects. ▪GoSub support is disabled by default in the -l ng fblite unless the Option Gosub ttatement is used.
Differences from QB
▪None when using the -lang qb dialect.
Sae also
▪Goto ▪Sub
|