From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to break while loop

Hello,
 
I would like to beak while loop. Is it possible?
I know how to stop it. When I say break I mean promptly exit the loop, like in other programming languages.
 
Thanks Eva
0 Kudos
Message 1 of 11
(12,124 Views)
Sorry Evca,

but you can't. But with the proper dataflow it is possible.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 11
(12,116 Views)
Hello,
 
Correct - there's not exact equivalent.  However, functionally, when you want to "break" from your loop, you just write the appropriate logic to your loop condition terminal.  Yes, that little logic has to be evaluated.  The general idea of a break (from a functional standpoint) is to "do nothing else in the loop and simply jump outside of that structure."  If you code carefully, you can guarantee that no other code will execute if those conditions are met - this will at least functionally implement breaks in your loop.  In a text-based language this would be equivalent to setting a condition which would cause your current iteration to skip all other code, and your subsequent while condition to evaluate to false - thus effectively stopping the loop, and having "done nothing else" after the "break condition" was met.
 
I hope this helps!
 
Best Regards,
 
JLS

Message Edited by JLS on 12-08-2006 04:33 PM

Best,
JLS
Sixclear
0 Kudos
Message 3 of 11
(12,074 Views)
Maybe somewhat related to your question is the discussion of a possible loop structure that checks the termination condition first and only then execues loop code accordingly.
 
 
 
0 Kudos
Message 4 of 11
(12,064 Views)

I have done something similiar to exit a test routine part of the way through a loop. I built my while-loop into a state machine and placed the "Break" into the states where I needed to break out the loop.

This example is a While-Loop with a start, middle and end section. The middle section can be skipped if the Break button is enabled.

I hope provides one idea on how to implement what you need

David

Message Edited by David Crawford on 12-09-2006 08:19 AM

Edit: Hadn't finished post.

Message Edited by David Crawford on 12-09-2006 08:22 AM

Download All
0 Kudos
Message 5 of 11
(12,055 Views)

Thanks for all your help. I've already solved my problem.

The main reason, I've wanted to break loop, was, because I use wait function in loop, and I want to stop it in the same time when stop condition is satisfied, and not after the time set in wait function, which can be in minutes, elapse. But it seams impossible, after I've read your answers.

Eva

 

0 Kudos
Message 6 of 11
(12,042 Views)
This wait and break can be done easily with a state machine or a queued message passing architecture.
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 7 of 11
(12,034 Views)


@Evca wrote:

The main reason, I've wanted to break loop, was, because I use wait function in loop, and I want to stop it in the same time when stop condition is satisfied, and not after the time set in wait function, which can be in minutes, elapse. But it seams impossible, after I've read your answers.


Use an event structure timeout case to time your code, eliminating any other wait function. Now create a second event case to interrrupt the loop. It will execute immediately, even if the timeout happens only every hour. 😉

For a simple example, look at my recent post here: http://forums.ni.com/ni/board/message?board.id=170&message.id=219301#M219301

(you can see that at certain points durimg execution the timeout is set to infinite, yet the loop can easily be stopped at all times.)

Message 8 of 11
(12,027 Views)
JLS;

I know the Purest's response is that we don't need no stinking "for while" "break".  I believe we need a new LabView "for while" loop that includes a break on error.

In the real world, equipment fails, errors out, is left turned off, not plugged in, etcetera.  LabView is supposed to be addressed to real world users, not theoreticians.  I've attached 2 jpegs of test loops that show how NI's intransigence forces real world users to construct their loops to handle real world events.  Simply stated, when programming electronic equipment with many different end users, there is a regular occurence of error events that the programmer must handle.  I think I program in the spirit of LabView, I think NI should bite the bullet and provide their customers with tools that save them time and effort, and that they continually ask for.

   ...Dan
Download All
0 Kudos
Message 9 of 11
(11,897 Views)

Dan,

You might consider providing feedback elsewhere, for example at the following link:

http://forums.ni.com/ni/board/message?board.id=features&message.id=7&jump=true

C. 🙂

0 Kudos
Message 10 of 11
(11,878 Views)