If I'm programming a subroutine, can I make it go back to the main thing? If I can, what is the syntax? Thanks ^_^
-Aika
Is it possible to CALL the main module in a program?
-
- Newbie
- Posts: 1
- Joined: Wed Jun 20, 2007 6:15 pm
Re: Is it possible to CALL the main module in a program?
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 ^$$$^
-Aika
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.
Regards..... Moneo