LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Binary File strips carriage returns (LV 8.2.1)

   I was using Write to Binary File to write a combination of strings, numbers, and time stamps.  When I later went to read the filel, it didn't quite make sense.  Although I had written strings that had lines ending in <CR><LF>, when I read them back in, they only had <LF>.  I checked this using other programs to read the file.  The <CR>'s have been stripped out!  Why would a "binary" file VI kindly edit your strings for you?  I needed the strings to be written exactly as they were.  The VI corrupted my data.
   I couldn't find any explanation for this in the help, nor any way to turn this behavior off.  Is this a known issue, a bug, or a feature?

Regards,
   Dave T.

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 1 of 6
(3,095 Views)
Sorry to hear about the trouble you were having.

The behavior you are seeing is not a bug. It is a type of feature meant to help maintain LabVIEW's platform independence. The idea as I understand it is that LabVIEW can convert your file automatically into one that has the expected EOL character(s) for that system, regardless of the data being written.

All that said, you can indeed turn off this behavior by right clicking the Write VI and unchecking Convert EOL. You should see the EOL glyph disappear from the VI icon.
Jarrod S.
National Instruments
0 Kudos
Message 2 of 6
(3,092 Views)
Jarrod,
   Thanks for the quick reply.  However, I think there is a bit of confusion still.
   The behavior you describe is indeed present in the Write to Text File vi.  It is not present (and in my opinion should NOT be present) in the Write to Binary File vi.  There is no right-click option on the Binary version and there is no EOL glyph.  It would not make any sense to include this in a binary file vi.  But the behavior of stripping the <CR> does still seem to be there.
   Frustrating...

Dave T.
-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 3 of 6
(3,086 Views)
In particular, this should only happen if you use "write to text file". "Write to binary file" does not have the "convert EOL feature" from what I can tell. (LabVIEW 8.0+). (The "convert EOL" does about the same as ascii ftp transfer does compared to binary ftp transfer.)
 
Which file IO tools are you actually using? can you attach a stripped down example of your code?
Message 4 of 6
(3,085 Views)
   Thanks, Altenbach and Jarrod, for your help.
   Time to eat crow.  At Altenbach's prompting, I created a sample program that would demonstrate the problem.  It didn't.  Turns out the files were fine.  I was reading them with the "Read from Text File" vi, with the EOL option enabled!  I had used another program to check the data in the file, and was basing my conclusion on that.  Unfortunately, I didn't use a good hex editor, and it turns out the program I used was also stripping the <CR> off.  So the data in the file was good, I was reading it wrong, and my double-check was reading it wrong.

Cheers,
    Dave
-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
Message 5 of 6
(3,080 Views)
Glad to hear it. And thanks to Altenbach for pointing out my mistake about the Write to Binary and Write to Text File functions.
Jarrod S.
National Instruments
0 Kudos
Message 6 of 6
(3,067 Views)