Total # lines in .txt file

Is there a function ( macro ) that returns the number of lines in text file ?
Macro is in Libre draw.

If not, any eloquent recommendations to find total number lines in text file?

Depending on which operating system you use, why not open the .txt document in Notepad++ or NotepadQQ, each of which will display line numbers and give you the total number of lines in the document.

Yes, that would provide line numbers, but I would prefer not to have to manually input into macro in this case; rather have the macro check total lines itself automatically, rather then interrupting the macro’s sub-routine.

You say you are using a .txt file and your question is tagged Draw. How are you using Draw with .txt files?

Then when you write “# lines”, what you actually mean? are you talking about a line as any amount of text between two line breaks (various depending on TXT kind: Linux/macOS line ends differ from Windows line ends), which usually would translate into paragraph count (but would also be more complex if import is not configured correctly to consider proper kind of line ends, or if the file includes several kinds of line ends), or the lines that result from laying out (and wrapping) that text in some component of LibreOffice (e.g., in a text box in Draw)?

Maybe your macro wants to read a text file itself (e.g., using “com.sun.star.ucb.SimpleFileAccess” and “com.sun.star.io.TextInputStream” services), and so is in fact not specific to used component?

"How are you using Draw with .txt files ? "

Macro to read .txt file, and then output desired data (strings/text/etc) to multiple draw pages via textbox(es).

See answer by @Regina to this question for an example of the code to read a text file line by line.

In a decent command line shell enter wc -l filename.txt

Seems it’s possible with a no so decent command line link text like type *.EXT | find /c /v "" :slight_smile: