Quickly retrieve the lines from a text file
This function quickly retrieves a range of lines from a text file.
AI
AI சுருக்கம்: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
மூலக் குறியீடு
<hr>
<b>Quickly retrieve the lines from a text file</b><br><br>
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:<br><br>
Writeln('The 2nd line in c:\autoexec.bat is '+GetLinesFromFile('c:\autoexec.bat',2,2)[0]);
<br><br>
<b>function GetLinesFromFile(filename:string; linestart, lineend:integer) : TStringList;</b><br>
(*<br>
// Name : GetLinesFromFile<br>
// Purpose : Returns a series of lines from a text file, starting at linestart and going to lineend<br>
// Date : 12 Feb 2001<br>
// Comments :<br>
*)<br>
var<br>
fn : textfile;<br>
c : word;<br>
Line : String;<br>
begin<br>
Result:=TStringList.Create;<br>
AssignFile(fn,filename);<br>
Reset(fn);<br>
for c:=0 to LineStart do<br>
ReadLn(fn,Line);<br>
for c:=LineStart to LineEnd do<br>
begin<br>
Result.Add(Line);<br>
ReadLn(fn,Line);<br>
end;<br>
CloseFile(fn);<br>
end;<br>
<br>
Please vote for this code!
அசல் கருத்துகள் (3)
வேபேக் மெஷினிலிருந்து (Wayback Machine) மீட்டெடுக்கப்பட்டது