- Subject: Re: [slang-users] Question about the _for statement
- From: "John E. Davis" <jed@xxxxxxxxxxx>
- Date: Mon, 25 Apr 2022 14:35:54 -0400
Bernd Eggink <bernd.eggink@xxxxxxxxxx> wrote:
> the documentation says about the _for statement: "The loop will
> terminate when the value of the loop index exceeds last-value". It says
> nothing about what value the variable will have in this case.
> Apparently it is not last-value+1 as I had expected, but last-value.
>
> I'm fine with that, but can I rely on it?
After execution of the _for loop, the value of the variable will what
it was when it last exited the body of the loop. Here are some
examples:
variable i = NULL;
_for i (0, 10, 1)
{
}
% Here, i will be 10
i = NULL;
_for i (0, 10, 1)
{
i = i + 20;
}
% Here, i will be 30
variable i = NULL;
_for i (0, -10, 1)
{
}
% Here i will be NULL
You can rely upon this behavior.
Thanks,
--John
>
> Kind regards,
> Bernd
>
> --
> http://www.sudrala.de
> _______________________________________________
> For list information, visit <http://jedsoft.org/slang/mailinglists.html>.
>
_______________________________________________
For list information, visit <http://jedsoft.org/slang/mailinglists.html>.
[2022 date index]
[2022 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]