Showing results for 
Search instead for 
Did you mean: 

A basic question about String -> array

Hi, all,
I have an input String ":CURV 12,72,75,74,76,74,75,77,77,72,72,75,78,72, .....", totally 500 numbers, how can I change this to a 1-D array?
I tried to use "scan from string", but how to set up 'format string'? thanks
0 Kudos
Message 1 of 10
Since you have so many numbers, you shouldn't use scan from string. Instead, use a while loop to detect and convert each number, and output the result using auto indexing.
You can also take the first part off the string and use spreadsheet string to array with a comma as the seperator and a 1D U16 array as the type.

Try to take over the world!
0 Kudos
Message 2 of 10
I assume that this is the data retruned from an instrument. If that is the case I would recommend the Instrument I/O Assistant Express VI in the Express palette. It helps you set up the communication (which you already have working) and the parsing (which is the part you are having trouble with. It is really easy to use and helps out with most intrument communication when you don't have a driver.

Good luck
0 Kudos
Message 3 of 10
You can try the attached
Randall Pursley
0 Kudos
Message 4 of 10
Randall, I tried your code but it only transferres the first data (12) to the array, do I need a loop something? Thanks.
0 Kudos
Message 5 of 10
Eliminate the :CURV from the format string (just have %d) and then delete the first element from the array.
0 Kudos
Message 6 of 10
Randall's solution works id you modify it slightly:
0 Kudos
Message 7 of 10
Try this vi in attachment.
0 Kudos
Message 8 of 10
fahlers, you code works but it missed the first data, how come? Thank you.
0 Kudos
Message 9 of 10
As tst said in the first answer you got, remove the first part (:CURV) and then use Read From Spreadsheet.
Message 10 of 10