From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write structure to binary file and append

Solved!
Go to solution

I have a very simple problem that I cannot seem to figure out, which I guess doesn't make it so simple, for me at least.  I've made a little example .vi which basically breaks down what I want to to.  I have a structure, in this instance 34 bytes of various data types.  I would like to iteratively write this structure to a binary file as the data in the ACTUAL structure in my .vi will be changing through time.  I'm having trouble getting the data to be appended to the binary file rather than overwriting it since the file size is always 34 bytes regardless of how many times I run the .vi or run the for loop.

 

I'm not an expert, but it seems if I write a 34 byte structure to a file 10 times, the final product should be a binary file of 340 bytes (assuming I haven't padded or prepended with size).

 

One really strange thing is that I keep getting error #1544 when I wire the refnum out wire to the file dialog input on the write function, but it works fine when I wire the file path directly to the write function.

 

Can someone please swoop in and save me from this remedial task?

 

Thanks for all the help. NI Forum rules!

0 Kudos
Message 1 of 3
(2,662 Views)
Solution
Accepted by topic author AdamBlues

Did you consider reading the text of the error message? Don't set the "disable buffering" input to true - just leave that input unwired. Why do you want to disable buffering?

 

As a general practice, the file refnum should be stored in a shift register around the for loop instead of using loop tunnels, that way if you have zero iterations you will still get the file refnum passed through correctly. Also, there is no need for Set File Position inside the loop, since the file location is always the end of the last write unless it's specifically moved to another location. You might want it once outside the loop after you open the file, if you're appending to an existing file.

0 Kudos
Message 2 of 3
(2,651 Views)

Why is your advice in assisting others with LabVIEW always so condescending?  

 

I really appreciate the help, but being pompus and trying to embarrass me about it is not necessary.  Yes, I read the error message. I didn't understand it, so I came here.  

 

It seemed like an easy problem to fix, and after doing what you've suggested, it is working, but I am very reluctant to offer you any praise since this isn't the first time you've been an **bleep**.

 

Please don't answer any more of my posts, I'd rather deal with someone who is nice and willing to help out someone in need.

 

Best Regards,

 

Adam

Message 3 of 3
(2,645 Views)