LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

is it possible to exit the For Loop or Sequence Str.?

Hi All,

Does anyone know the way to exit the For loop prior to the end of n number
of loops? or skip certain frame(s) in a Sequence structure?

Thanks in advance,

Louis.
0 Kudos
Message 1 of 5
(2,952 Views)
If you think about something as "Break" in C, there is not such command in LabVIEW.
You can use For loop or Sequence with case structure for this target.
0 Kudos
Message 2 of 5
(2,952 Views)
Nadav is correct. There is not a way to implement a C "break" in LabVIEW. However, there are other ways to achieve what I believe you are wanting. This Knowledge Base talks about Case Structures and State Machines in LabVIEW and how you can use these for similar purposes. Best of luck.
J.R. Allen
0 Kudos
Message 3 of 5
(2,952 Views)
If there is not an easy way to do something, then this often means
that you are taking the wrong architectural approach and need to back
up and start over.

If you need to exit a for loop before it is done then what that really
means is that you need to reimplement this part of your code as a
while loop which is naturally designed for this purpose.

As for skipping frames in a sequence structure, I would recommend
first:

1) Avoid sequence structures as much as possible as they defeat the
parallelism inherent in LabVIEW and tend to obfuscate how your code
works to other programmers (and even yourself later on.)

2) I would recommend placing a case structure inside a while loop with
a single text case selector so that you could choose which cases to
execut
e more easily than putting a separate case selector inside each
frame of your sequence.

Douglas De Clue
LabVIEW developer
ddeclue@bellsouth.net


"blah blah" wrote in message news:...
> Hi All,
>
> Does anyone know the way to exit the For loop prior to the end of n number
> of loops? or skip certain frame(s) in a Sequence structure?
>
> Thanks in advance,
>
> Louis.
Message 4 of 5
(2,952 Views)
The only thing I would add is to recommend that you drop sequence structures completely. Except for single frame structures that you can use to establish a data dependency, there is no good reason for ever using a sequence structure.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 5
(2,947 Views)