LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

format string

high there,

i want to convert an ascii string like this:

1,54,42,10,4 ... and so on

into a vector of decimal numbers. i want to use the
to separate the commas from the string but i do not know which format
string to use. i tried several things ('%s,' or '%s ,') whithout success.

anyone has an idea?
thanks in advance,
\ulli.
0 Kudos
Message 1 of 4
(3,028 Views)
Use the "Spreadsheet String To Array" function. It will do what you want without any programming. Wire a comma to the delimiter input. You may have to use 2D array as the array type, and then convert to a 1D array with the "Index Array" function. (disable indexing on first index, wire "0" to second index).
0 Kudos
Message 2 of 4
(3,028 Views)
I fully agree, Spreadsheet String to Array a very powerful function and a a good way of doing this. In fact, it works on 1D arrays as well. All you have to do is wire an empty 1D array to the Array type input. The default is a 2D array though. /Mikael
0 Kudos
Message 4 of 4
(3,028 Views)
In LabVIEW there is a funtion that does exactly what you want to do! It is called Spreadsheet String to Array and it can be found under the string functions.

Provide it with the format %d for integers or %f if your numbers are fractional numbers.

I attached a simple example that shows how it works. The example is compatible with LabVIEW 4.1 and up. Hope this helps. /Mikael
0 Kudos
Message 3 of 4
(3,028 Views)