LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write File does not accept refnum-behaviour is strange

Hi,

I have come across an odd thing in LV6i under Mac OS 9. When I create a data file using the New File library VI and then connect the output refnum to the input of the Write File function, there is no problem there.

But suppose I encapsulate the New File function in another Vi, let's call it "Test New File.vi", so that there is nothing else but the library New File.vi and all its controls and indicators exposed (wired them up with the connector pane, of course). This, it seems to me, should be an exact equivalent of the original New File.vi, but it isn't. When I connect the refnum to the input of standard Write File.vi, it will deny the data input wire claiming a non-sensical error:

You have connected two terminals of different types ->
These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Help window to see what data type is required.
The type of the source is string.
The type of the sink is string.


Oddly enough the Write File.vi does not complain about the refnum at all and does not complain about the data type, when refnum is not connected. I have attached samples to demonstrate this.

Does anybody know, what goes on in there?
Thanks!

Daniel
Download All
0 Kudos
Message 1 of 5
(2,857 Views)

Hi Daniel,

This problem is happening because you have wired the Datalog Type input of the New File function in the subVI.  When you do this, the New File function outputs a reference to a datalog file.  If you do not wire this input, LabVIEW outputs a reference to a binary file.  You'll notice that if you try wiring an I32 into into the Write File that you have wired to your subVI reference output, the wire will no longer be broken.

So the solution, in your case, would be to remove the "datalog type" input from your subVI so that the reference generated by the New File function in your subVI is a reference to a binary file, not a datalog file.

Hope this helps,

-D

P.S. - You can learn more about the difference between binary files and datalog files in the LabVIEW Help.

Message 2 of 5
(2,855 Views)
Hi Darren,

thank you for your suggestion, but I cannot see the problem solved. I am attaching another VI here, one that I am actually trying to use. Inside, as you will observe, the datalog type input is not wired, while it still causes the came problem, when used in the previously attached "Testing.VI" (result attached now as Testing2.vi).

Thank you very much for trying to help me!
Daniel
Download All
0 Kudos
Message 3 of 5
(2,850 Views)

Hi Daniel,

Look at your VI more closely...turns out you do have something wired to the datalog type input of that function...a Boolean wire, in fact.  Try again.

-D

P.S. - The way I was able to figure this out quickly was because I had the Context Help window open, and when I hovered over your New File function, the "datalog type" was shown in the window as a boolean wire.

Message Edited by Darren on 01-25-2006 05:18 PM

Message 4 of 5
(2,848 Views)
Drat! :-)))

NOW a lot is clear, even the fact, why the refnum looked like a boolean indicator! It happened that in my ancient VI (similar to the Testing.vi) I was using the Open/Create/Replace.vi, which has a boolean connected at the advisory dialog? input. Then I used the menu function Replace->New File.vi and the damage was done-the boolean automatically got wired where a willing acceptor was found!

Thank you very much for finding this error for me.
Cheers!
Daniel
0 Kudos
Message 5 of 5
(2,842 Views)