Quickly retrieve the lines from a text file

Submitted on: 1/1/2015 4:50:00 AM
By: Bob Brown (from psc cd)  
Level: Intermediate
User Rating: By 7 Users
Compatibility: Delphi 5, Delphi 4, Pre Delphi 4
Views: 3981
     This function quickly retrieves a range of lines from a text file.

Quickly retrieve the lines from a text file

If you need a quick function to get a line from a text file, try this one. It's very simple to use, for example:

Writeln('The 2nd line in c:\autoexec.bat is '+GetLinesFromFile('c:\autoexec.bat',2,2)[0]);

functionGetLinesFromFile(filename:string; linestart, lineend:integer) : TStringList;
// Name : GetLinesFromFile
// Purpose : Returns a series of lines from a text file, starting at linestart and going to lineend
// Date : 12 Feb 2001
// Comments :
  fn : textfile;
  c : word;
  Line : String;
  for c:=0 to LineStart do
  for c:=LineStart to LineEnd do

Please vote for this code!

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.