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

Fabien Bodard gambas.fr at gmail.com
Mon Jan 14 13:09:06 CET 2019


We lose this ability but won the one of inline declaration

For each hControl as Control in MyForm.Children

Next

Le dim. 13 janv. 2019 21:38, Benoît Minisini <g4mba5 at gmail.com> a écrit :

> 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
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190114/26ba4006/attachment.html>


More information about the User mailing list