08-01-2012 01:23 PM
I have a conditional FOR loop with a STOP button, however, due to the data flow nature of LabVIEW, the stop button is being polled at some point prior to the end of the loop. Since a control has no input, I can't connect the last operation in a single iteration of the loop to trigger the polling of the STOP control, and I'd rather not use a flat sequence just for the stop button if I can avoid it. I've considered using an event structure, but I don't want to force the loop to wait for the stop button to be pressed, I simply want the loop to EXIT, *IF* the stop button is pressed...but I want the stop button to be polled at the END of the loop, so if the user presses the stop button at any point in the loop, at the end of that iteration, the loop will terminate....does that make sense? Currently, since the stop button is polled once at some arbitrary time durring the loop iteration, if the user presses the stop button after it is polled, the loop then has to execute an additional iteration, and I don't want that to happen.
...anyway, I guess I'm just looking for a more elegant way to implement this than having to use a flat sequence just for the stop button.
Solved! Go to Solution.
08-01-2012 01:36 PM
Any chance you can post a code snippet so that we may see what you are trying to accomplish?
08-01-2012 01:40 PM
The most elegant way will be a flat sequence structure where all of the code in the loop will execute in the first frame, and the stop button is read in the second frame.
08-01-2012 01:45 PM
08-01-2012 01:48 PM
Nope. The stop button can and probably will be read early in the loop iteration. Only the boolean OR and feeding of that to the stop terminal will wait on the rest of the code.
08-01-2012 01:56 PM - edited 08-01-2012 01:56 PM
Sorry, but you are going to have to use a sequence structure. That's why they are there. They do have their purposes occasionally. Here's how I would handle it.
08-01-2012 01:58 PM
I guess I'm just looking for a more elegant way to implement this than having to use a flat sequence just for the stop button.
Wanna try Stacked Sequence Structure?
Or you can connect a wire to a flat sequence around stop button.
How much more elegant solution are you looking?
If dont wanna poll you can switch to event structure, but dont look elegant neither good technique.
Best Regards,
08-01-2012 02:01 PM
Actually, my issue with the flat sequence was primarily a space contraint, but I just tried a stacked sequence and I think it will work better.
Thanks guys.
08-01-2012 02:03 PM
No. Don't use a stacked sequence. It hides code. You can see from Crossrulz's picture that the flat seqence won't take that much space.
08-01-2012 03:08 PM
Oh yeah, I forgot about being able to use the error status as an entry tunnel to the flat sequence with a single frame. That should work. That's what I was looking for! Thanks!