break out of a while loop from outside the loop


I have an application where I have some nested while loops.  Is it
possible to break the innermost loop from a control that is outside of
the inner loop?  My inner loop is running a scan and read operation on
the serial port and is reading data as it somes in.  I need this loop
to break when the user presses a button located in one of the outer
loops so that another section of the vi can execute.  Thanks in

x9561 (148438)
7/29/2004 4:43:29 PM
comp.lang.labview 35210 articles. 1 followers. vasusachin24 (1) is leader. Post Follow

5 Replies

Similar Articles

[PageSpeed] 10

Create a local variable to outer control and wire it in the inner post
loop. When you set the value of outer control, the local variable
accessed its value in the inner loop.

A Rafiq
x9561 (148438)
7/29/2004 4:52:01 PM
You should place the terminal of the button in the innermost loop and
wire out from there to the other locations the value is needed. If
these are nested loops, the controls will not get read until the outer
loop iterates again and this can only happen if the inner loop has
ended anyway. Thus your scheme will not work.

Alternatively, you can place the control in a loop that executes in
parallel,then use local variables of it in the other locations, but
the above solution is better.
x9561 (148438)
7/29/2004 4:53:45 PM
Ok, I put my 5 buttons into my innermost loop and wired them into the
loop stop control.  My question now is:  My innermost loop is within a
sub vi, how can I make these button controls available to the user on
the control panel of the main vi?
x9561 (148438)
7/29/2004 5:16:37 PM
Ahhh well, this is an entirely different scenario! Now we have 5
buttons and the loop is inside a subVI!

If the front panel of the subVI is visible, users could press the stop
button there.

In a more general case, use two independent while loops in the main
VI, one to run the user interface and one to lauch the subVIs. Now you
can communicate with the subVI using e.g. notifiers, "functional
globals" or global variables, etc..
x9561 (148438)
7/29/2004 8:35:48 PM
Ok, here is what I did and it seems to work fine.  I created a while
loop right next to my sub vi call in the main vi.  Since there is only
one loop in the sub vi, the two loops are in parallel.  I then encased
both the new while loop and the sub vi into a third while loop.  I
created a global varable that took the booleen output and used it to
stop the loop with my buttons as well as the loop in the sub vi, then
passed it on to the outer loop to stop that one.  The structure then
passed on the correct data to the case in my outer loop.

Thanks a million for your help!

x9561 (148438)
7/29/2004 9:03:36 PM