LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting out of a For Loop

I am running a FOR loop but on occasions I want to bail out of it based on
an event occurring. Is there any way to do this or am I stuck with
implementing a While loop? My concern is that a While loop is slower than a
FOR loop and I need the speed provided by the FOR loop as the FOR loop
allocates all of the memory in advance. Thanks in advance for your help,
-Tom
0 Kudos
Message 1 of 3
(1,585 Views)
This subject has been beaten like a red headed step child in the past 2-3
weeks. Search using 'for loop' in recent posts, you will get plenty of input.

"Tom Byers" wrote:
>I am running a FOR loop but on occasions I want to bail out of it based
on>an event occurring. Is there any way to do this or am I stuck with>implementing
a While loop? My concern is that a While loop is slower than a>FOR loop
and I need the speed provided by the FOR loop as the FOR loop>allocates all
of the memory in advance. Thanks in advance for your help,>-Tom>>
0 Kudos
Message 2 of 3
(1,585 Views)
Use the FOR loop when you KNOW that an action shall be executed a known
number of times

....and use the WHILE loop if you don't know if processing og the data or an
external event shall allow you to break out the loop!

FOR IF == WHILE ??

Hans Øhra
Principal scientist
NDRE


"Tom Byers" wrote in message
news:3a8c5082@newsgroups.ni.com...
> I am running a FOR loop but on occasions I want to bail out of it based on
> an event occurring. Is there any way to do this or am I stuck with
> implementing a While loop? My concern is that a While loop is slower than
a
> FOR loop and I need the speed provided by the FOR loop as the FOR loop
> allocates all of the memory in advance. Thanks in advance for your help,
> -Tom
>
>
0 Kudos
Message 3 of 3
(1,585 Views)