LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically write data to an open file in a different sub vi

Hi,
 
Is it possible to open a file to write data in one sub vi, pass the ref num to that file to another sub vi and write data to it in append mode ?
 
Cheers,
Carnot
0 Kudos
Message 1 of 9
(3,584 Views)
The simple answer is yes. Why do you ask? Are you having some sort of problem?
Message 2 of 9
(3,579 Views)
Well... why not ?
It seems like the answer is included in the question ? Have you tried ?

You can either let the file open and pass the refnum, or close the file, pass the path and re-open in the sub VI...


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 3 of 9
(3,576 Views)
I'm opening a spreadsheet in Excel in one sub VI and then writing data to it in another sub
VI using the refnum within a While loop.  At this point I'm getting "An input parameter is
invalid." error.
 
There's no error when the While loop is not there.  The error is the same if you were to pass the
refnum across two frames of a Flat Sequence.
 
Cheers.
0 Kudos
Message 4 of 9
(3,566 Views)
hi there
 
please post some code so we can have a look at it.
 
best regards
chris
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 5 of 9
(3,562 Views)

Hi,

Here's the code where I'm using two frames (which is equivalent to two sub vis executing one after the other).

Cheers.

0 Kudos
Message 6 of 9
(3,559 Views)

hi there

please see the attachment. you have to close the file only ONCE after you are done with it. when closing the file in each cycle you get the error you mentioned after trying to write to the file after it has been closed. please read the comments i added to the vi.

 

.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 7 of 9
(3,556 Views)
Hi Chris,
Thanks for that mod code.  I was closing the file in each iteration of the while loop by including the Close File function within
the sub VI.  That might have been the one causing the prob, yeah? 
Regards.
0 Kudos
Message 8 of 9
(3,550 Views)

yeah.

 

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 9 of 9
(3,544 Views)