If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!
4 posts • Page 1 of 1
If I'm programming a subroutine, can I make it go back to the main thing? If I can, what is the syntax? Thanks ^_^
First of all, are you referring to a SUB or a gosub type subroutine?Aikaterine wrote:If I'm programming a subroutine, can I make it go back to the main thing? If I can, what is the syntax? Thanks ^$$$^
In the case of a SUB:
- The SUB usually gets called by the main module, although SUBs can also be called by other SUBs or Functions.
- You get back to the main module or whoever called the SUB by it's ending statement of END SUB.
In the case of a gosub subroutine:
- Subroutines are invoked via a GOSUB. They can be invoked from the main module or from a SUB or Function when the subroutine is part of these.
- You get back from a subroutine by it's ending statement of RETURN. You can have multiple RETURNs in a subroutine, although it's not good practice.
- Beware of exiting a subroutine using a GOTO. This may eventually cause a stack overflow error.