LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For loop, possible to increment counter/exit loop?

I would like to know if it is possible to exit a For loop. I know
I can use a while loop but it would be nice to be able to
increment the loop counter in a for loop. Is this possible?

Thanks,
Mike
0 Kudos
Message 1 of 4
(1,868 Views)
Mike Scirocco wrote:

> I would like to know if it is possible to exit a For loop. I know
> I can use a while loop but it would be nice to be able to
> increment the loop counter in a for loop. Is this possible?
>
> Thanks,
> Mike

No sorry it is not possible.
If you need this kind of functionality you will have to use a while loop.
You can then setup all manner of conditions to exit the loop.
Be aware that the loop will always run at least ONCE.

A for loop will run X number of times. This is determined either
at compile time (if the count is hard coded) or at run time
(if you use auto-indexing, or the count is a variable).

Kevin Kent
0 Kudos
Message 2 of 4
(1,868 Views)
Also remember you can make while loops auto index. Right pop on the tunnel
and enable this and the loop will then act more like a for loop.

Jim

"Kevin B. Kent" wrote:

> Mike Scirocco wrote:
>
> > I would like to know if it is possible to exit a For loop. I know
> > I can use a while loop but it would be nice to be able to
> > increment the loop counter in a for loop. Is this possible?
> >
> > Thanks,
> > Mike
>
> No sorry it is not possible.
> If you need this kind of functionality you will have to use a while loop.
> You can then setup all manner of conditions to exit the loop.
> Be aware that the loop will always run at least ONCE.
>
> A for loop will run X number of times. This is determined either
> at compile time (if the count is hard c
oded) or at run time
> (if you use auto-indexing, or the count is a variable).
>
> Kevin Kent
0 Kudos
Message 3 of 4
(1,868 Views)
Jim,

OK, that clears it up. Coming from VB I'm still figuring out the
differences.

Thanks,
Mike

James Morrison/Joan Lester wrote:
>
> Also remember you can make while loops auto index. Right pop on the tunnel
> and enable this and the loop will then act more like a for loop.
>
> Jim
>
> "Kevin B. Kent" wrote:
>
> > Mike Scirocco wrote:
> >
> > > I would like to know if it is possible to exit a For loop. I know
> > > I can use a while loop but it would be nice to be able to
> > > increment the loop counter in a for loop. Is this possible?
> > >
> > > Thanks,
> > > Mike
> >
> > No sorry it is not possible.
> > If you need this kind of functionality you will have to use a while loop.
> > You can then setup all manner of conditions to exit the lo
op.
> > Be aware that the loop will always run at least ONCE.
> >
> > A for loop will run X number of times. This is determined either
> > at compile time (if the count is hard coded) or at run time
> > (if you use auto-indexing, or the count is a variable).
> >
> > Kevin Kent
0 Kudos
Message 4 of 4
(1,866 Views)