LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble using global variable for file reference

Solved!
Go to solution

Hi all,

 

This code is trivial but illustrates the problem I am having.  I want to open a file with vi A, dynamically open vi B, pass the file reference to vi B, close vi B, then close the fiel with vi A.  vi B is designed to continuously sample data and add it to the file.  Unfortunately I can't implement this solution because it appears that global variables do not work for file references(!).  Thanks!

0 Kudos
Message 1 of 3
(2,657 Views)
Additional comment: the attached code fails because of invalide file reference.  If the global variables are removed and the wire is connected directly, the code works fine.
0 Kudos
Message 2 of 3
(2,651 Views)
Solution
Accepted by topic author j_osh_o
You have a race condition in that picture.  The global variable refnum out could be read at the File write before the File Open has had a chance to write a valid file reference to the other global variable refnum copy.  You should have a wire from the Open to the write directly.  If you want to store it in the global variable as well, then branch it off that direct wire.
Message 3 of 3
(2,648 Views)