Page 1 of 1

Is it possible to CALL the main module in a program?

Posted: Wed Jun 20, 2007 6:18 pm
by Aikaterine
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

Re: Is it possible to CALL the main module in a program?

Posted: Wed Jun 20, 2007 7:03 pm
by moneo
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
First of all, are you referring to a SUB or a gosub type subroutine?

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

Posted: Thu Jun 21, 2007 7:00 am
by OPRESION
Use Exit Sub anywhere into the subrutine

Posted: Mon Jun 25, 2007 10:24 am
by Erik
Once your sub ends it dumps you right back to the line after it was called. :)