Read X number lines from text file to variable

Is it possible to read only the top 20 or 30 lines from a text file into a variable?  As part of a build, I read the version history for the current build in to a variable and then use that variable in an email message.  Since this history can get pretty long, I only need to send the top 20 or so lines in the message,  Can that be done with the Read Text File action?  I'm using FB 6.1.0.866

You can try using the File Contents Iterator action. You’ll have to use some script in the OnAfterEachIteration event to stop after the number of iterations you want, eg.

if (Action.LineIndex > 19)
{
Action.Reset;
}

How would you add each line to a variable and keep the carriage return/line feeds?

It should by default keep the new line breaks within the variable.

Since you're putting the variable into an e-mail, be aware that a setting in outlook will automatically remove extra line breaks. So it may appear that there are no new lines, but there actualy is. I've had this problem myself.

http://support.microsoft.com/kb/287816

Otherwise try some new line characters i.e. \n

 

Also when you concatenate strings, you can add a CRLF, eg. MyString = MyString + vbCRLF