From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
lvABC

String Get Number of Lines

Status: New

LabVIEW native primitive to get string’s number of lines.

 

Just an example:

string number of lines.png

 

Also, Get Number of Lines could be extended to File IO function too, File Get Number of Lines.

8 Comments
AristosQueue (NI)
NI Employee (retired)
In the palettes, find the function "Pick Line". Used in a loop, it does what you're wanting to do.
Jim_Kring
Trusted Enthusiast

Great idea!

 

You can also use the OpenG Multi-line String to Array function.

 

OpenG Multi-line String to Array.png

lvABC
Member

Aristos Queue,

How so?
I want to find out how many line are there in string!

 

Jim Kring,
You are right, I do have OpenG lib (who doesn’t):), and used that vi.
Thank you for sharing.


loop.png

Jim_Kring
Trusted Enthusiast
@lvABC: You're welcome. I'm glad that works for you 🙂
Knight of NI

You can also use the Search and Replace String function that you're using by using the "number of replacements" output. For example:

C:\Documents and Settings\smercurio\Local Settings\Temp\Example_VI_BD.png

 

lvABC
Member

smercurio_fc,
You are absolutely right Sir!
I never thought of that, part could be that I was also looking to ignore empty lines.
I am sure there could be many other ways to get number of lines, I just posted one of them.

 
Still learning LabVIEW, haven’t fully come out of dark side.

Thanks

Jim_Kring
Trusted Enthusiast

lvABC, here's how you can filter empty lines, using the OpenG Filter 1D Array function:

 

Filter Empty Lines.png

AiraVaat
Member

Another easier way to chop-up each line in an array. Input is an Multi-line string and with a power of for-loop you can set the Count (N) terminal to some high-number which you may never reach. However, the Conditional terminal will stop the loop right after there are not more lines thus you will exit out of the loop soon as numbers of lines have been detected. Cons may be you might an empty element at the end which needs to be removed. That is not hard once you have lines filled in as an elements of an array. Try it see if it you guys like it!! 

 

MultiLine String to Array.png

 

Cheers!

Max