ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to array - more elegant solution possible?

Hello, I have a string that contains different status information. These are separated by \n\r. Now I would like to transfer each status message into an array field. My solution works, but I find it very complicated. Does anyone have an idea to solve it more elegantly?

 

Thanks a lot for your help.

 

Best regards,

Michael

2020-04-09_15h57_49.png

2020-04-09_15h58_07.png

  

0 Kudos
Message 1 of 7
(3,789 Views)

Yes, it looks complicated…

 

 

There surely someone comes up with a RegEx solution to filter all those EOL chars…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(3,776 Views)

String to array optimized.png

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 7
(3,773 Views)

2020-04-09 String to Array.png

Message 4 of 7
(3,739 Views)

@Yamaeda wrote:

String to array optimized.png


I would have done this except leave the delimiter unwired (the EOL is handled already in the Spreadsheet String To Array).  I have actually ran into this enough that I have a VI that does the FOR loop to eliminate empty strings in my arrays.  I also have a similar one for NaN in floating point arrays.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 7
(3,708 Views)

Remember that "scan string for tokens" (by default) collapses multiple consecutive delimiters into one, offering yet another simple solutions:

 

 

altenbach_0-1586454054536.png

 

This simplifies things, because if does not matter if the delimiter is \n\r, \n, \r\n, \n\r\n\r, etc.

 


NOTE: Of course this is an an opportunity to remind people of my old idea:

 

Contract multiple delimiters for "Spreadsheet string to array" 

 

Please vote for it! Thanks! 😄

 

Message 6 of 7
(3,703 Views)

If you have OpenG library, use it in the following way. Simple!

 

 

Bathank_0-1586457089500.png

 

Message 7 of 7
(3,686 Views)