LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

subvi to close old file file then open a new one

I'd like to write a subvi to:

1. close an exiting text file using a file refnum as one of the subvi inputs

   a. How to test for file open or ignore attempted close on an unopened file (refnum)

   b. I can't find the "refnum" in the tool pallets.

       Where is it so I can create the input and output parameters to the subvi?

2. open a new text file using:

    a. path to existing directory (input to subvi)

        like: z:\MainData\SubData\

    b. file sequence number (input to subvi)

           seqnum: 001 ... 999

       A changed "seqnum" should be the trigger to cause the file close and new file creation.

       An unchanged "seqnum" should cause the subvi to simple pass the input refnum to the output refnum.

        (this would be done with a simple true/false case structure)

    c. create a new file named: z:\MainData\SubData\data-001.csv

    d. output the new refnum to be used in the main vi to write the data.

 

Also part of this involve multiple while loops:

1. data display loop (100 Hz) from the DAQ/control system (this data has already been saved)

2. command loop (waits for something to change on the GUI to generate a command to the DAQ/control system)

3. This new loop (1Hz) to collect data from a network instrument, display it on the GUI, and save the data.

Loops #1 & #2 live together just fine. Will loop#3 cause any interference with the other loops?

 

Thanks, Joe

PS. I only create new VIs ever year or so. My Labview skills always atrophy so doing new things seems much harder then it should be.

0 Kudos
Message 1 of 2
(2,158 Views)

1a) Just use the reference and handle the resulting error when you try to close an invalid reference.  Probably just use Clear Error.

1b) Right-click on a file reference output on a file IO node and select Create->Control.

2) In the File IO->Advanced palette is the Create File With Incrementing Suffix.vi.  You could just use it directly or make a copy and edit as needed.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 2
(2,152 Views)