01-04-2011 12:03 PM
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.
01-04-2011 12:13 PM
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
01-04-2011 12:57 PM
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?
01-04-2011 01:08 PM
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
01-04-2011 01:25 PM
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.
01-04-2011 01:39 PM
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
01-04-2011 01:41 PM - edited 01-04-2011 01:42 PM
Use get file size and then set file position.
It looks like johnsold posted as I was writing
01-04-2011 03:31 PM
using version 8.6, yep that seemed to work, thanks.