LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write at a specific address using pos mode and pos offset

I want to reserve the first 100 bytes for a binary file and start writing raw data from the 101th byte address.  I try to use "write file" vi with pos mode and pos offset.  I keep getting error of "End of file encountered".  Here is my code.
 
Thanks,
Shan
0 Kudos
Message 1 of 3
(2,366 Views)
Shan,

Look at the help file for Write File.vi:

"Write File Details
If the location computed by this function occurs before the beginning of the file, for example if pos mode is 0 and pos offset is –10, this function places the file mark at the beginning of the file and returns an error. If the location occurs after the end of the file, for example if pos mode is 1 and pos offset is 10, this function places the file mark at the end of the file and returns an error."

If your file is empty assigning a pos offset of 100 will produce an error. Try writing 100 null characters (hex 00) to the file and then overwriting later with your header.

Lynn
0 Kudos
Message 2 of 3
(2,359 Views)
I got it to work.  Thanks a lot Lynn!
0 Kudos
Message 3 of 3
(2,352 Views)