07-16-2008 07:12 PM
07-16-2008 09:26 PM - edited 07-16-2008 09:26 PM
For a traditional For loop, I don't know of any way to stop it early.
In LV 8.5, there is now a conditional For Loop. You can expose a Stop terminal within the For loop with a right click and checking "Conditional Terminal". Sending a True to that would cause it to stop.
07-17-2008 01:59 AM
07-17-2008 08:09 AM
There seems to be a disconnect in what I am asking....
I understand how to stop a for loop BUT once that for loop is in a consumer que event and starts to run how do you send a BOOL into that same consumer Que event once the for loop has started to run. Once the for loop runs inside an event doesn't it become a blocking event until the for loop completes?
Thanks
Tim C.
07-17-2008 08:24 AM - edited 07-17-2008 08:25 AM
Perhaps you can post a screenshot of the code you have so far. When you say "consumer queue", I'm visualizing the the consumer loop in a producer/consumer architecture. Or do you have an event structure? Or are registered for user events? I'm not sure if any of these would matter for the issue of stopping a For loop early, which is what I thought was the reason for your question.
The easiest way would be to pass the stop command into the loop by way of a local variable. Notifiers or occurrences would be a more advanced way to pass along information instead of the "not always evil" local variable.
Please post an example of what you have now so we can more clearly see what you want to do.
07-17-2008 09:00 AM
You are correct that once a case in a consumer starts executing, the next item will not be consumed until the current one has finished.
Since you want to send the stop command into the same queue, you basically have to run the "for loop" (or whatever) asynchronously, either by launching a dynamic VI call using the Run VI method or by running it in a separate loop. In both cases, you can stop it by using a named notifier.
07-17-2008 04:00 PM
07-17-2008 04:41 PM
For a simple one to one relationship, I would just but the button in the For loop and take it out of the Event structure. Set it to switch when release and manually reset it back to false with a local variable when the case structure completes. See Attached.
If it gets more complicated then this, then I would start looking at notifications and occurrences tied in with the event structure.
07-17-2008 05:29 PM - edited 07-17-2008 05:30 PM
07-17-2008 07:58 PM
The cancel function will get more complicated, as i was planning on using a common cancel button to cancel For Loops in multiple consumer
events.
What are "Que Occurances" (I think that is what you mentioned)?
Thanks
Tim C.