[Gambas-user] Beware of the restriction on global variables.

Benoît Minisini g4mba5 at gmail.com
Sun Jan 13 21:37:46 CET 2019


Le 13/01/2019 à 15:45, Gianluigi a écrit :
> Before the new changes in the declaration of local variables, it was 
> possible, even if I do not understand the reason, to declare a global 
> variable to use it in this way:
> 
> Private hControl As Control
> 
> Public Sub Form_Open()
> 
>    For Each hControl In Me.Controls
>      Print hControl.Name
>    Next
> 
> End
> 
> Now this code is no longer possible.
> 
> Regards
> Gianluigi
> 

A loop variable must be local, because of the interpreter and the JIT 
compiler. It was possible to use any variable with FOR EACH, but that 
was a mistake.

-- 
Benoît Minisini


More information about the User mailing list