キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

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 件の賞賛
メッセージ1/7
3,850件の閲覧回数

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
メッセージ2/7
3,837件の閲覧回数

String to array optimized.png

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

Qestit Systems
Certified-LabVIEW-Developer
メッセージ3/7
3,834件の閲覧回数

2020-04-09 String to Array.png

メッセージ4/7
3,800件の閲覧回数

@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
メッセージ5/7
3,769件の閲覧回数

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! 😄

 

メッセージ6/7
3,764件の閲覧回数

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

 

 

Bathank_0-1586457089500.png

 

メッセージ7/7
3,747件の閲覧回数