LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I specify an exit routine to run after a loop?

I would like to initialize a routine, but only after a loop has completely finished running.  If the loop runs three times, such that n=0..2, then I could create a routine that only runs if i=2; the only problem is that (I think) the routine would run during the final iteration of the loop rather than after that itiration has finished.  Is there a standard way of creating an exit routine like this?
0 Kudos
Message 1 of 4
(4,257 Views)
Place the code after the loop and create a data dependency so it cannot start until the loop has finished.
0 Kudos
Message 2 of 4
(4,242 Views)
Yes, I tried doing that in a variety of ways, and the best I could do when creating a data dependency, was to trigger that dependency on the last step of the loop, which made it so my 'exit' routine would run simultaneously with the last step of the loop.

What I ended up doing was to add one more iteration to the loop, and inside the loop add a case structure that would run my loop code during the normal iterations, but run the exit routine during the final loop.  This works quite nicely.

Thanks for the assistance.
0 Kudos
Message 3 of 4
(4,238 Views)
A "data dependency" is not something that you "trigger", but is a natural component of dataflow.
 
For example, in the following picture you could place code insde the sequence frame. Since the sequence frame depends on data coming out of the while loop, it MUST wait until the loop has finished (even if your exit routine does not even use the wire for anything else as in this case). Most often you don't even need a sequence frame but can utilize the error cliuster for data dependency.
 
Remember: A structure cannot execute until all inputs have received data and a structure only produces data on its ouputs once it finishes.
 
It's all in the dataflow! 🙂

Message Edited by altenbach on 03-04-2007 04:34 PM

Message 4 of 4
(4,236 Views)