LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read file before executing everything else in VI

Solved!
Go to solution

I am using the "Read from measurements file" .vi to read read in a .lvm file containing the data I want to use in my VI.  I have two different files I need to read into the VI.  After I click "run" the prompt comes up and I select my desired file, then the other prompt shows up, along with everything else running in the VI which is in a while loop, but I do not want anything to run in the while loop until the 2nd input is selected.

 

Is there anyway for the program to wait until those two files have been read in? 

 

Capture.PNG 

These are the "read from measurement file" vi's that I want to input the data with before having everything execute in the VI. 

0 Kudos
Message 1 of 6
(3,126 Views)
Solution
Accepted by topic author cmersits

simply wire the "error out" of the two reads to the edge of the while loop. This creates a data dependency and forces execution order.

 

Even easier, delete the local variables and wire directly from the reads to where the data is needed inside the while loop. 😄

 

(Why would you need to read the same data from the same terminal over and over with every iteration? Makes no sense! Terminals belong outside the loop unless you expect them to change during execution of the loop. Do they?  Can you attach the entire VI? Is the array actually used as a control by the user? If not, make it an indicator.)

Message Edited by altenbach on 12-10-2009 06:44 PM
Message 2 of 6
(3,120 Views)

Simple if you understand dataflow. The simplest and best would be to wire the output of the read functions into the loop and directly to where you have the control. Unless you want the user to change it, change the controls to indicators. Otherwise, use the error out terminals from the read function to control dataflow. For example, if you simply wire them to the edge of the loop, they will execute first.

 

p.s. You do not need to 'adjust' your loop counts. Wiring an array through a for loop will take advantage of the built-in auto-indexing feature and you do not need to wire anything at all to the for loop's 'N' terminal. This is pretty basic stuff. Have you taken the tutorials or taken any type of training?

Message 3 of 6
(3,116 Views)
Using a sequence structure worked for me.  The error out seems like an easy fix too.  Thanks for the help guys!
0 Kudos
Message 4 of 6
(3,105 Views)
It's a slight misstatement to call using the Error Out an "easy fix".  That's the proper way to control execution order in LabVIEW, while using a Sequence Structure is a "fix".
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 5 of 6
(3,073 Views)

jcarmody wrote:
It's a slight misstatement to call using the Error Out an "easy fix".  That's the proper way to control execution order in LabVIEW, while using a Sequence Structure is a "fix".

Actually, the correct way would be to get rid of the local variable and turn the array control into an indicator or eliminate it completely. Is the array control even shown on the front panel?

 

While the error out is the second choice, it could possibly still lead to a race condition. Since the start of the while loop and the writing to the two local variables can occur in parallel righ after the last file dialog has completed, the error out alone is not 100% safe (well, it probably is, but why take the risk ;)).

 

cmersits,

Please show us your code so we can provide some guidance. I have the feeling that you are doing this way more complicated than needed.

0 Kudos
Message 6 of 6
(3,054 Views)