Jump to content
Macro Express Forums
USslang

How to determine the number of lines (records) in a text file?

Recommended Posts

How to find out with MacroExpress Pro how many lines are there in text document? What is the command... I searched the help file, couldn't find it...

Share this post


Link to post
Share on other sites

The easiest way I found was:

  1. Create the special character Carriage Return or Line feed. (Newline)
  2. Copy the text of the first variable to a second variable.
  3. Remove all instance of the CR or LF from the second string variable. 
  4. Subtract the number of characters of the second string variable from the original variable. The difference is the number of newlines.
  5. Add 1 to that value.

You may want to trim the original text first to ensure there is not a trailing newline set. 

  • Like 1

Share this post


Link to post
Share on other sites

Or, if you are just looking for number of RECORDS (as you say in the title of your posting) -- use Text File Begin Process, which transfers the records one at a time into a variable, and you can add to a counter each time through. 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×