Nice work! About "occupying" the Return keyword, why not simply use something like "Return Gosub" indicating that you only want to return from the Gosub, and not the whole function? And as I said before, the code inside a gosub must somehow use control variables in a deeper depth or what you say, otherwise they can be overwritten. Recursive gosubs might be even harder...
Dim i As Integer Dim j As Integer For i = 1 To 10 Gosub label1 Next Return label1: For j = 1 To 3 Print "Yeah!!";; i;; j Next Return does not print out "Yeah!!" 30 times as expected. It prints out this: Yeah!! 1 1 Yeah!! 1 2 Yeah!! 1 3 Yeah!! 2 1 Yeah!! 2 2 Yeah!! 2 3 Yeah!! 3 1 Yeah!! 3 2 Yeah!! 3 3 So the control variables for the first loop get changed by the second loop. /Emil 2012/3/4 Benoît Minisini <gam...@users.sourceforge.net> > 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 > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user