LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting and retrieving a string

hey,

I want to split the input string after every special character ($) coming from com port and want to save it in a 2D array, then I want to retrieve the splitted string in its orignal form from array and send it to com port ...

Can anyone help ???

Thanks in advance

0 Kudos
Message 1 of 6
(2,314 Views)

Spreadsheet String to Array and use $ as the delimiter.

Reverse is Array to Spreadsheet String

Message 2 of 6
(2,302 Views)

@Arslan125

 

Here's sample code I made for you. Let me know if that helps. 

0 Kudos
Message 3 of 6
(2,292 Views)

@atul_ghumade wrote:

@Arslan125

 

Here's sample code I made for you. Let me know if that helps. 


I don't think atul_ghumade's code will work as-is. The last For Loop to recreate the original data is flawed. It assumes that the com data has only two columns, so you may lose data. ex. a string of "1$2$3$4$5" will truncate to only "1$2". Also, the tunnel mode of the loop is set up as Indexing, so the output would be a 1D array.

Use RavensFan's recommendation and use Array to Spreadsheet String for the reverse process.

SampleCode_rev1.png

0 Kudos
Message 4 of 6
(2,278 Views)

Thanks its really helpfull

0 Kudos
Message 5 of 6
(2,273 Views)

Might as well (or slightly better actually) make that a 1D array. Right click the 2D array constant and select "Remove Dimension".

 

Also remember that the Array to Spreadsheet String always adds a \n to the end. You might want to remove that before sending.

Message 6 of 6
(2,253 Views)