LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

local variables for refnum

I've tried various things but I can seem to write to a file using local variables for refnums.
Help please.
0 Kudos
Message 1 of 3
(3,150 Views)
exo,
 
Try wiring the error output of the 'Open/Create/Replace File' primitive to the 'Write to Text File' primitive.  This will ensure that the file is created before it is written to.  When you use local variables, the risk of race conditions is introduced, which is what is happening here.  There is no problem with passing refnums by local variable, just as long as you make sure that you are reading the variable after its value has been set.  I would suggest only using local variables if absolutely necessary, which is almost never.
 
Also, I suggest wiring a control to the stop terminal of the while loop, instead of a constant.  A constant 'False' value means that the loop will run forever, unless you abort the VI.  Aborting a VI should only be done as a last resort.
 
Chris M
0 Kudos
Message 2 of 3
(3,148 Views)
Thanks.
0 Kudos
Message 3 of 3
(3,138 Views)