LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FOR loop termination?

Is there any way in LabView to terminate FOR loop from the inside
before it executes N times? Something like "break" instruction in C. It
seem like a simple question, but I couldn't find a simple solution :-).
thanks,
chris
0 Kudos
Message 1 of 10
(3,208 Views)
Is there any reason not to use a While Loop? If you use
this kind of loop you can stop it when you want.
Best Regards

Gorka


* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
0 Kudos
Message 2 of 10
(3,206 Views)
>Is there any reason not to use a While Loop? If you use
>this kind of loop you can stop it when you want.
>

I have a need to break out of a FOR loop that is using auto-indexing. I have a
IF-THEN in the loop with a null ELSE clause, but I hate to run a few thousand
null loops just to exit "early."
Randall Miller
0 Kudos
Message 5 of 10
(3,206 Views)
Randall Miller wrote:

> >Is there any reason not to use a While Loop? If you use
> >this kind of loop you can stop it when you want.
> >
>
> I have a need to break out of a FOR loop that is using auto-indexing. I have a
> IF-THEN in the loop with a null ELSE clause, but I hate to run a few thousand
> null loops just to exit "early."
> Randall Miller

To answer the original question there is not a way to break out of a "For Loop".
The solution above (or similar) is all that is available.
Kevin Kent
0 Kudos
Message 7 of 10
(3,206 Views)
yes it is,
sometimes I need to run the loop 0 times. While Loop runs at lest one time, as the condition is checked at the end of the loop. One can build the logic to
run a While Loop 0 times, but in my case design becomes pretty complicated.
In other words I can accomplish what I want, but I hoped to simplify my VI.
best regards,
chris

Gorka Larrea wrote:

> Is there any reason not to use a While Loop? If you use
> this kind of loop you can stop it when you want.
> Best Regards
>
> Gorka
>
> * Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
0 Kudos
Message 3 of 10
(3,206 Views)
In article <39367174.217C9614@alf.ifj.edu.pl>,
chris szybinski wrote:
>yes it is,
>sometimes I need to run the loop 0 times. While Loop runs at lest one time, as the condition is checked at the end of the loop. One can build the logic to
>run a While Loop 0 times, but in my case design becomes pretty complicated.
>In other words I can accomplish what I want, but I hoped to simplify my VI.
>best regards,
>chris

Perhaps you could put a select comparison function in there and send the
results to the loop? WHile false, it will not run, and while true, it
will. Just a thought without any background into your program.

Harry
0 Kudos
Message 4 of 10
(3,206 Views)
this is exactly what I've done :-). But it would be much easier to be able to break the loop.
chris

Harry King wrote:

> In article <39367174.217C9614@alf.ifj.edu.pl>,
> chris szybinski wrote:
> >yes it is,
> >sometimes I need to run the loop 0 times. While Loop runs at lest one time, as the condition is checked at the end of the loop. One can build the logic to
> >run a While Loop 0 times, but in my case design becomes pretty complicated.
> >In other words I can accomplish what I want, but I hoped to simplify my VI.
> >best regards,
> >chris
>
> Perhaps you could put a select comparison function in there and send the
> results to the loop? WHile false, it will not run, and while true, it
> will. Just a tho
ught without any background into your program.
>
> Harry
0 Kudos
Message 6 of 10
(3,205 Views)
I know this is not exactly what you are asking for, but I will mention it anyway.

There are two ways to stop a For Loop. The first is to use the auto-index like you are doing. The other is to wire a value to the N input before starting the
loop. The loop will stop on the first occurence of EITHER of these methods. If you want the convenience of auto-indexing, but know that you will not want to
process all of the values in the array, try to determine the quantity before entering the loop. Then wire that value to the N input. A value of 0 will prevent
any iterations of the loop from executing.

Good luck.
--
Michael Munroe Mailto:mmunroe@abcdefirm.com
A Better Complete Development Engineering Firm
San Mateo, CA 94403 ht
tp://www.abcdefirm.com

chris szybinski wrote:

> this is exactly what I've done :-). But it would be much easier to be able to break the loop.
> chris
>
> Harry King wrote:
>
> > In article <39367174.217C9614@alf.ifj.edu.pl>,
> > chris szybinski wrote:
> > >yes it is,
> > >sometimes I need to run the loop 0 times. While Loop runs at lest one time, as the condition is checked at the end of the loop. One can build the logic to
> > >run a While Loop 0 times, but in my case design becomes pretty complicated.
> > >In other words I can accomplish what I want, but I hoped to simplify my VI.
> > >best regards,
> > >chris
> >
> > Perhaps you could put a select comparison function in there and send the
> > results to the loop? WHile false, it will not run, and while true, it
> > will. Just a thought without any background into your program.
> >
> > Harry
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.0, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 8 of 10
(3,205 Views)
CTRL period will stop the program.


In article <39354B52.49F41576@alf.ifj.edu.pl>, szybinsk@alf.ifj.edu.pl says...
>
>Is there any way in LabView to terminate FOR loop from the inside
>before it executes N times? Something like "break" instruction in C. It
>seem like a simple question, but I couldn't find a simple solution :-).
>thanks,
>chris
>
0 Kudos
Message 9 of 10
(3,205 Views)
Charles.Sheehe@lerc.nasa.gov (Charles Sheehe) wrote:
>CTRL period will stop the program.

Okay, but I think the poster wanted to stop the loop when a condition was
met without stopping the program. In that case (at least from a purist CS
point of view), a while loop would be a better construction, using two guards
joined by an OR operator: one that stops the loops after a given number of
iteration, and the other that stops the loop if a condition is met.

-Asher

>>>In article <39354B52.49F41576@alf.ifj.edu.pl>, szybinsk@alf.ifj.edu.pl
says...>>>>Is there any way in LabView to terminate FOR loop from the inside>>before
it executes N times? Something like "break" instruction in C. It>>seem like
a simple question, but I couldn't find a simple solution :-).>
>thanks,>>chris>>>
0 Kudos
Message 10 of 10
(3,205 Views)