[Gambas-user] Gambas has Gosub now!
Benoît Minisini
gambas at ...1...
Sun Mar 4 01:05:52 CET 2012
Hi,
I have just succeeded (I think) in implementing the old Basic GOSUB
instruction in Gambas in revision #4530.
I did that, because it is faster than using a plain little function, if
you just need to call a small piece code without needing a specific
context nor arguments.
The syntax is the same as the GOTO instruction (with the same
restrictions on the label):
GOSUB <label>
To return from a GOSUB, you must use the RETURN instruction alone.
<label>:
...
RETURN
Consequently, you cannot use RETURN to return from a subroutine if there
is a pending GOSUB. A little annoyance.
If the function end (or a CATCH instruction) is encountered, the
function is ended like before, even if there are pending GOSUB. In other
words, returning from a GOSUB is always explicit.
Enjoy it!
--
Benoît Minisini
More information about the User
mailing list