 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Andrew Guest
|
Posted: Mon Sep 29, 2003 8:08 pm Post subject: Re: How to read a specified line of text from a text file? |
|
|
On Tue, 30 Sep 2003 02:35:41 +0800, "¤pRay" <rsquare52 (AT) hotmail (DOT) com>
wrote:
| Quote: | Dear all,
Would you mind telling me how to read a specified line of text from a text
file ?
eg, what should I use if I want to read the 4th line only, but not the 5th
and the 3rd?
Can Readln do this?
Thanks in advance.
try this |
var
TempList: Tstrings;
index:integer;
FileName :string;
begin
FileName:='times.txt';
if fileexists(filename)then
begin
TempList:= TstringList.Create;
try
with Templist do
begin
loadfromfile(Filename);
for index:=0 to templist.count-1 do {enable to process line
by line}
begin
if index=4 then main.Ename.text :=templist[index];
end;
end;
finally
TempList.Free;
END;
end;
end;
Andrew K.
http://www.users.bigpond.com/andrew.s.kennedy/
|
|
| Back to top |
|
 |
?Ray Guest
|
Posted: Tue Sep 30, 2003 4:49 am Post subject: Re: How to read a specified line of text from a text file? |
|
|
thank you very much!
"Andrew" <andrew.s.kennedy (AT) bigpond (DOT) nospam.com>
???????:bd4hnvkakj6bos7r7id4dp5d8sc26cdo2i (AT) 4ax (DOT) com...
| Quote: |
On Tue, 30 Sep 2003 02:35:41 +0800, "¤pRay"
wrote:
Dear all,
Would you mind telling me how to read a specified line of text from a
text
file ?
eg, what should I use if I want to read the 4th line only, but not the
5th
and the 3rd?
Can Readln do this?
Thanks in advance.
try this
var
TempList: Tstrings;
index:integer;
FileName :string;
begin
FileName:='times.txt';
if fileexists(filename)then
begin
TempList:= TstringList.Create;
try
with Templist do
begin
loadfromfile(Filename);
for index:=0 to templist.count-1 do {enable to process line
by line}
begin
if index=4 then main.Ename.text :=templist[index];
end;
end;
finally
TempList.Free;
END;
end;
end;
Andrew K.
http://www.users.bigpond.com/andrew.s.kennedy/
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|