LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop a while loop while in a for loop

Is there a way to stop a program while it's insides some embedded for loops?  I've been trying using events, but I am still stuck inside my embedded for loops.  Basically, I have 3 embedded for loops, which do a total of... 600 iterations, all of these loops are inside a while loop... I would like to be able to stop the while loop (and hence my program) while I'm in the for loops... is this possible?

 

Thanks 

0 Kudos
Message 1 of 5
(3,052 Views)
Depends on your version of LabVIEW. You need to stop the for-loops before you stop the while loop. With 8.5 the for-loop has a conditional stop so you can stop the for-loops.  If you have pre-8.5 then you need to have a case structure around your code in each for-loop so that when you press the Stop button the code is skipped. Of course, you need the have the control's terminal in your innermost loop so it actually gets read there. You could also use a local variable instead of the terminal in this case. (Queue local variable haters here. Smiley Very Happy)
Message 2 of 5
(3,048 Views)

The best solution is the one provided by smercurio. You can also use a "quick and dirty"-solution: In the Application-Control-palette, there's a "STOP"-Vi which does the same the red button in LabVIEW does...it stops the program. If you place it into a case-structure into your for-loops, you can also stop your program. You have to place your cleanup-stuff (if any) BEFORE executing this stop...for example by adding a sequence-structure into the case-structure and adding the cleanup in a frame before...

 

Hope this helps,

 

Greetings, 

 

Christian

 

 


THINK G!! 😉
------------------------------------------------------------------------------------------------
Using LabView 2010 and 2011 on Mac and Win
Programming in Microsoft Visual C++ (Win), XCode (Mac)
Message 3 of 5
(3,028 Views)
Ah ok thanks, I've got 8.5 so I'll go with the conditional on the FOR loops, I'm new to LabVIEW and just thought that "events" and event structures were similar to 'interupts' in other programming languages, and that they would execute no matter what your program is doing.... 
0 Kudos
Message 4 of 5
(2,986 Views)
Interrupts are something different. Interrupts are usually hardware-based, though they can also be software. An interrupt will usually call a callback routine. Event handling in LabVIEW is not really that much different from event handling in other programming languages. While an event can occur, it's up to you to actually have an event handler active to deal with it. In other programming languages (i.e., text-based like C/VB) this typically means having a function that is registered to be called by the operating system when that event happens. In LabVIEW you have an event case that's registered for the event.
Message 5 of 5
(2,977 Views)