Gosub : Return
DescriptionGosub MyLabel MyLabel: ... Return
Gosub stands for 'Go to sub routine'. A label has to be specified after Gosub then the program will continue at the label position until it encounters a Return. When a return is reached, the program is transferred below the Gosub. Gosub is very useful when building fast structured code.
Another possibility to put a sub routine into a standalone program component is to use procedures.Example:
a = 1 b = 2 Gosub ComplexOperation Debug a End ComplexOperation: a = b*2+a*3+(a+b) a = a+a*a Return
DescriptionFakeReturn
When you want to jump from a sub routine (with the command Goto) to another part in the code outside of this sub routine, you need to use a FakeReturn which simulate a return without do it really. If you don't use it, your program will crash. This function should be useless because a well constructed program don't use Goto. But sometimes, for speed reason, it could help a bit.Example:
Gosub SubRoutine1 SubRoutine1: ... If a = 10 FakeReturn Goto Main_Loop EndIf Return