LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Variant saved to text file becomes corrupt and unreadable, any suggestions?

I'm using variants to save configuration data for an application that I'm building.  Specifically, the configuration data is packaged in a cluster of a cluster and an array of clusters.  Within the first cluster is an image path, two doubles and two ints, and each element within the array of clusters is a string and two doubles.

 

I convert this cluster to a variant and then the variant into its pieces (Variant To Flattened String.vi), convert the array of I16's to strings, concatenate the array of strings with the data string into another array, and then save that array to a spreadsheet file in a text file.  I close the text file as soon as this is done.

 

The exact opposite procedure is done to get the cluster out of the text file.

 

This VI executes within the scope of a much larger program with other things concurrently happening.  The process works most of the time.  I can both save to and load from the text file.  However, sometimes, and I am really at a loss as to when, this process fails because there is a failure translating the variant.  The text file is then corrupt and can no longer be read.  Has this problem ever been seen before, or does anyone have any idea where I can start in debugging this?

 

Thanks.

0 Kudos
Message 1 of 5
(3,451 Views)

What are you using to write to file? What is your LabVIEW version? Can you post some code to show what you're doing? VI is preferred.

 

Without details on what you're doing, my guess is that you're using the Write Text File and have the EOL conversion turned on, so everytime LabVIEW sees a linefeed character it converts it to the EOL character(s) for the operating system you're on. On Windows this would be CR/LF. I believe on Macs it's CR and on *nix it's LF.

Message 2 of 5
(3,432 Views)

Is the type def of the cluster (the one being saved) change?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 5
(3,421 Views)

Hi Smercurio,

 

Thanks alot!! I searched this same issue, and that is exactly what was wrong. I already started to create a work around figuring that these variants couldn't be written to a text file for some reason, but the EOL conversion was my issue.

 

-Anthony

0 Kudos
Message 4 of 5
(3,186 Views)

Glad to hear that fixed your problem. Smiley Wink

0 Kudos
Message 5 of 5
(3,174 Views)