LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open file in Sub VI and close in Main VI

Hi,
 
Question:
 
I am opening a file using a Sub-VI, but i am unable to close it in my main VI. Is there a way of passing the refnum between Sub-VI's ?
Or is there a cleaner way of doing this ?
 
Thanks
GM
0 Kudos
Message 1 of 4
(2,763 Views)
Hi,
You can pass the refnum. Use Controls=>Refnum=>Byte Stream File Refnum and Change to indicator
or just right click on the refnum output node of the open file vi and select create=>indicator.
Dai

LV 7.1 - WIN XP - RT - FP
0 Kudos
Message 2 of 4
(2,758 Views)
Hi,
You can pass the refnum. Use Controls=>Refnum=>Byte Stream File Refnum and Change to indicator
or just right click on the refnum output node of the open file vi and select create=>indicator.
Dai

LV 7.1 - WIN XP - RT - FP
0 Kudos
Message 3 of 4
(2,757 Views)
Although this can be done, it is not good programming practice to do so.  You should open files in one vi, read/write to them in the same vi or in subvi's, and close the file at the level where it was opened.  This is proper modular programming.  Then you would not need references.  You could just wire the file refnum into your subvi.  Of course this is a general statement.  You could have a very good reason why you are doing it your way.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 4
(2,745 Views)