04-25-2017 07:25 AM
Hi Everyone,
I have faced one problem in handling binary file. One part of my program is flatten a cluster into a string and write that string into a binary file. In some other part of the code is open the file and read the data as a string then unflatten into cluster. Writing into a binary file execute only once. But frequently program reads the file depending upon the condition. During this read operation i got a error Data Structure Corrupted in unflatten function, Error Code 74. And the file size is reduced from 34kb to 100 bytes. Herewith i have attached one good binary file, one corrupted binary file and the VI snippet.
Please help me on this.
Thanks in advance
04-25-2017 07:30 AM
I'm not sure why there may be corruption of the file, can't download your snippet to see the read side of the vi, but can you do a single read into a storage element (an uninitialized shift register, a.k.a LabVIEW 2 global) and then read that data? In the read portion are you reading in the whole file, or are you only reading parts? I try, for many reasons, to avoid lots of reading/writing of files, if only for speed reasons.
04-25-2017 07:43 AM
04-25-2017 11:52 PM
Hi Gerd,
are you suspect flatten and unflatten function?. it was running fine in my other software's.
04-26-2017 12:15 AM
Read and Write wont comes very frequently. Read takes place when user change file to operate. they will change the file maximum once per a day.
04-26-2017 12:47 AM
Hi sankar,
are you suspect flatten and unflatten function?
No, but the file function can handle clusters on its own. No need for (Un)Flatten and string length handling…
(Most often VIs with less functions are easier to handle/debug!)
Can you make sure you never write an undefined (aka "empty") cluster to your file?
Can you make sure you never get any file access errors?
04-26-2017 01:15 AM
There's no need to set the file pointer to Start, if the file is just opened, that's the default.
/Y
04-26-2017 01:15 AM
Can you make sure you never write an undefined (aka "empty") cluster to your file? - Actually there is no way to write empty data. Because When user create new file i have passed default values in that empty cluster. User change the default values and then save it to hard disk. For my knowledge never empty values passed to the cluster.
Can you make sure you never get any file access errors? - No. Nothing like that.