LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is possible to set a specific delimiter in Format Into File?

   I need to program a Header file builder with several fields copied from control inputs. I want to open this file in Matlab, so I need to separate fields with semicolon ( ; ).
   I programmed two VIs using Build/Split String.vi and Format Into File.vi.
 
   The first one (Build/Split String) is working but is more complex to split the fields. The other VI is not working yet because I don´t know how I set semicolon as delimiter in Format Into String and recover the informations with Scan From File.
 
   Could anyone help me? I´m programming with LV 8.0 and Windows XP.
 
Thanks in advance!
 
 
 
 
 
0 Kudos
Message 1 of 9
(4,415 Views)
Do you see the % sign on the format into /from file?

This allows you to define the formatting.  You can set this to "%s:%s:%s:%s" and you'll get a : separated data set.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 2 of 9
(4,388 Views)
I think you are doing this way too complicated. Why are all your numbers already strings?
 
Why don't you use "array to spreadsheet string" and "spreadsheet string to array" with the desired format, delimiter, and array dimensionality? All this can be done with code the size of a postage stamp. 😉
0 Kudos
Message 3 of 9
(4,383 Views)
Hi Klein,
 
You can use the Array to Spreadsheet String and Spreadsheet String to Array functions to automatically insert and parse out your semicolon delimeters.  See the attached image (I would have sent you the VI, but I don't have LabVIEW 8.0 on this PC.)  Hopefully this gets you up and running!
 
Cheers,
Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 4 of 9
(4,382 Views)

Hi Shoneil,

 

   I’m really not experienced with format syntax elements.

   I modified my VI with your suggestion and created a string constant ( %s;%s;%s;%s;%s ) on format string inputs.

   It’s working for Format Into File: it makes a TextFile just like I wanted. But the Scan From File VI outputs an error using the same format string:

 

Error 85 occurred at Scan From File (arg 2) in Header builder - Format Into File.vi

Possible reason(s):

LabVIEW: Scan failed. The input string does not contain data in the expected format.

 

What’s still wrong? Could it be the User notes string control? This field has a string with several white spaces..

 

Thanks!

 

 

0 Kudos
Message 5 of 9
(4,358 Views)

Hi Altenbach and Spex.

     Using the Array to Spreadsheet String and Spreadsheet String to Array is a great alternative solution!

     It really works very well with any delimiter, as semicolon. So, I’m sending the modified VI.

Thanks again!

 

LabVIEW 8.0

0 Kudos
Message 6 of 9
(4,352 Views)
 
You're almost home. 🙂
 
Please check the help on "spreadsheet string to array". If you wire a 1D array of string as type, that what you'll get! No slicing needed later.

Message Edited by altenbach on 03-22-2007 04:27 PM

0 Kudos
Message 7 of 9
(4,350 Views)

Of course if you have LabVIEW 8.20, the spreadsheet file IO tools can handle strings directly, simplifying the code. 🙂

 

Message Edited by altenbach on 03-22-2007 04:38 PM

0 Kudos
Message 8 of 9
(4,345 Views)

Ok, Altenbach

I got all modified settings!

And I finally realized which is the meaning of the array type input. It is used to indicate the structure wired into the Spreadsheet String To Array.

I'm already using the LabVIEW 8.2 version. The spreadsheet file VIs is sincerely the best way to manipulate my header information.

Thanks, my best regards!

 

0 Kudos
Message 9 of 9
(4,334 Views)