LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format File - String Length Problem

I decided to use "Format File" as a way to save data from one program to be opened in another, because it seemed like the easiest way to bundle and unbundle the different types of data.
My format is "%d;%d;%s;%s" where I used ";" as a separator.

The problem is such: when my string is too long with spaces in between, for example: "5;10;XXXX          XXXX            XXXX;OOOO". The "Scan for File" function only reads the XXXX as the 3 input.
and if it's too short, like "5;10;XX;OO", then my 3 input becomes XX;OO.

How do I make sure that my entries are clearly distinguished from eachother so that I could retrieve them with "Scan File". And how do I tell the program that, for example, the 3rd entry will have exactly 60 characters.

Thanks
Aleks.
0 Kudos
Message 1 of 3
(2,668 Views)

If both programs are LabVIEW use save XML.  It will store anything (at least everything I have thrown at it) to an XML formated file and It is much easier.  If you need to move it between different programs post a small VI witht the string in question and I will look at it.

Matt

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 3
(2,656 Views)
The format specifier %s stops scanning at spaces. It has to stop somewhere because in principle, all the rest of the file is a string.

To scan semi-colon separated strings, use the format "%[^;];" that means: scan for characters differents from semi-colon followed by a semi-colon.


LabVIEW, C'est LabVIEW

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