LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control subvi execution order

I have a test program with 2 subVIs and the first one simply creates a text file and writes a large string to it, the second one writes another string to the same file and then closes it. Is there a way to set execution order as the subVI that writes and then closes the file seems to be executing first. The subVis are independent from each other. Thanks.

0 Kudos
Message 1 of 8
(4,220 Views)

Make them dependent.  Usually this is done with the error cluster wires.  Also the file refnum or path could be used.

 

This is called dataflow and is the fundamental paradigm of LV.  If you have not done so please take some to work through the on-line tutorials for LV.

 

Lynn

0 Kudos
Message 2 of 8
(4,218 Views)

thanks for the reply, will take a look at more samples as I have done a lot of C#, C++, Object orientated design in the past but new to Lab View.  Do you have to make the general error handler an output of each subvi using the (show connector) at the subvi icon?

0 Kudos
Message 3 of 8
(4,202 Views)

No.  Just wire the error out of the first VI to the error in of the second VI.

 

When you switch from a text-based language to LV, the hardest thing to realize is that the position on the diagram has essentially nothing to do with the order of execution.  The dataflow concept is very powerful but quite foreign to text programming.  The core point is that any node (function, subVI, structure,...) may begin to execute when data is present at ALL of its inputs.  Similarly, the node's outputs are not available until the node completes its execution.

 

Lynn

 

dataflow.png

0 Kudos
Message 4 of 8
(4,195 Views)

I was able to get it to work except just had a general file I/O question.  Do you know if with the first subvi if I just open and write to a text file, with subsiquent subvis that I want to write to the same file (append data) do I just use the (write to text file function) and would I have to provide a file handle to it?  The first subvi creates and writes to the text file but I need to append to the file when additional subvis execute.  The other option would be to create write and close the file with the first subvi and then open the same file for appending with subsiquent subvis, but I did not see an append option with the Open/Create/Replace File function.

Thanks.

0 Kudos
Message 5 of 8
(4,188 Views)

It depends on which version of LV you are using because some of the options have changed. The Append/Overwrite is not a part of the Open function, but is handled at the time of each read or write.  Some of the higher level functions like Write to Spreadsheet File have an Append? input.  On the lower level Write to Text file or Write to Binary File, you need to use the Set File Position function (in the Advanced File Functions palette).

 

It is a good habit to keep the Context Help window open while wiring code.  When you are not sure about the details, clicking on the Detailed Help link will take you to a more comprehensive coverage of the item.

 

Lynn

0 Kudos
Message 6 of 8
(4,178 Views)

Use get file size and then set file position.

 

It looks like johnsold posted as I was writing Smiley Very Happy

=====================
LabVIEW 2012


0 Kudos
Message 7 of 8
(4,177 Views)

using version 8.6, yep that seemed to work, thanks.

0 Kudos
Message 8 of 8
(4,159 Views)