LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

square in front of data when writing to file

When I gather up a bunch of strings in a while loop, after I write the data to a file, the first line always has 3 spaces followed by a square. What is happening and is there a workaround to the problem.
I included sample code of what Im trying to accomplish, essentially, the while loop has a string concantanation for each line in the file I am trying to write to, everything works great but the darn square problem is putting a damper on my progress.

Any help is greatly appreciated!!
Thanks
David
0 Kudos
Message 1 of 6
(2,832 Views)
Hi David,
I think your problem could come from your way of writing into the file. It's better to write a string than an array of strings into a file.
Try to convert your array into a single string and write it to the file.

I've attached an LV6.1 Version of your VI modified.
Hope this helps !
Julien
Message 2 of 6
(2,832 Views)
sweet, thanks a lot! That fixed the problem. I am still wondering what causes that problem, is it a bug in LV?
0 Kudos
Message 3 of 6
(2,832 Views)
I have no idea if it's a bug or not. All I know is that converting an array to a string is not so painful in LabVIEW so it doesn't matter.

Regards,
Julien
0 Kudos
Message 4 of 6
(2,832 Views)
It's not a bug. When an array is written to a file, there is extra information stored when the data is flattened to a string (i.e. array size). There is a shipping document entitled "LabVIEW Data Storage" that explains this (Help>Search the LabVIEW bookshelf). If you use the File Read with a data type defined as a string array, then you would get back your original string array.
0 Kudos
Message 5 of 6
(2,832 Views)
Look up how arrays are stored and you'll see what's happening.

An array is a 32-bit integer, followed by the elements in the array.
The integer indicates how many items follow.
By flattening the array, you are including the integer in the outpout string - the first four characters, if treated as a number will tell how many elements follow.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 6
(2,832 Views)