[Gambas-user] Gambas has Gosub now!
    Benoît Minisini 
    gambas at ...1...
       
    Sun Mar  4 02:23:57 CET 2012
    
    
  
Le 04/03/2012 02:03, Emil Lenngren a écrit :
> 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
>
You are right, I didn't think about that. So the current design does not 
work, and I don't have another one.
I will remove GOSUB if it cannot be implemented in a right way. :-/
Regards,
-- 
Benoît Minisini
    
    
More information about the User
mailing list