LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I parse strings into arrays

I am designing a Graphical User Interface in LabWindows CVI. I want to parse string from text box into array. For instance, if I get 1, 3, 5, 7, 9 in the text box, I want to create an array with elements 1, 3, 5, 7 and 9
0 Kudos
Message 1 of 2
(3,639 Views)
Once you have read the text box into a string, you can use two different methods to parse it:
1. If you know exactly how many items to scan, you can use Scan function with the appropriate specifier for the terminator character (as in your example, "%s[xt44]" terminates scanning on a comma)
2. If you don't know how many items to scan, you can use strtok function, scanning your string in a loop until its end (i.e. when strtok returns NULL)
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(3,639 Views)