FOR and FOREACH

Previous topic - Next topic

François Vanzeveren

Hello all,

In the help, I read for "FOREACH" the following
Quote
FOREACH ref in feld[]
...
NEXT

During the loop, "ref" will be a pointer (BYREF) variable to each element in the array.
You do not need to define "ref" as LOCAL.
It will be done automatcally, and it will invalid after the corresponding NEXT command.

I am wondering wether it is also the case with the "FOR" command: do we need to define the counter as LOCAL or is it done automatically?

Best regards

François

Moru

If I expect a local counter I would preffer to declare it local to be safe. In the current version it is declared as GLOBAL but that might change. I don't get an error message when not declaring it so I expect it to change soon :-)

François Vanzeveren

Thanks for this advice. I will follow it.

Note to glbasic authors: it would be helpfull to mention the LOCAL/GLOBAL status of counters for loops commands.

Regards

Kitty Hello

You're right. Should this be LOCAL automatically? Sounds handy.

Moru

Local to the for/next loop would be handy yes