user62039
user62039

Reputation: 371

In LabView, how to run a block only after exit from a while loop?

In LabView, I want to take some readings into a Measurement File in a while loop and run a Read From Measurement File block only after exit from a while loop as below:

enter image description here

How can I achieve this event driven running?

P.S. Other blocks are removed for convenience.

Upvotes: 1

Views: 729

Answers (2)

Dave_St
Dave_St

Reputation: 452

Enforce execution order with an error wire as shown.

enter image description here

Upvotes: 2

nekomatic
nekomatic

Reputation: 6284

Wire error out from your Write to Measurement File function to error in of the Read from Measurement File.

LabVIEW dataflow works like this: data does not appear at the output terminals of a function, VI or structure (such as the While loop) until the loop completes, and a function, VI or structure does not execute until data is available at all input terminals that are wired. So the Read will not execute until the error data is output from the completed While loop.

Using the error wire to enforce the order of execution like this is common practice in LabVIEW, and has another advantage: most VIs are written to not perform their function if an error is present at error in, but instead 'fall through' and return the same error at their output. So you can wire up a chain of operations linked by the error wire and catch and handle any errors at the end of the chain.

If you want more precise control over how LabVIEW handles errors look at the help, but this page describes how to specifically ignore an error if you don't want it to stop your program, and this site has a good overview of techniques for error handling.

Upvotes: 1

Related Questions