BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: How to read a specified line of text from a text file?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Non-Technical
View previous topic :: View next topic  
Author Message
Andrew
Guest





PostPosted: Mon Sep 29, 2003 8:08 pm    Post subject: Re: How to read a specified line of text from a text file? Reply with quote





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





PostPosted: Tue Sep 30, 2003 4:49 am    Post subject: Re: How to read a specified line of text from a text file? Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Non-Technical All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.