Board index » delphi » textfile read problem

textfile read problem

hello;

I am using Delphi 2 and trying to read a simple test file a line at a time. I
have written the code (see below) as outlined in the hlpe files and manual.
but the problem occurs that whenever i try to run the program I get an error
at the "Reset(R):" line saying missing operator or colon!.. i cannot figure
out what i am doing wrong or how to correct this. I hope someone can help.
procedure..... var R :TextFile; name : string; begin  AssignFile(R,
'drivers.txt');  Reset(R);  Readln (R,name);  dr1name.Caption := name;
Readln (R,name);  dr2name.Caption := name;  Readln (R,name);  dr3name.Caption
:= name;  CloseFile(R); end;

thanks Greg Hounsell PS I wrote to this file on another form with no probs
usng the same basic format but with proper coding of course :)

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

 

Re:textfile read problem


Try using a stringlist in stead of what you've writting so far.

mystrings:=tstringlist.create;
mystrings.loadfromfile(yourfilename);

and you've read your file !

ghoun...@cgo.wave.ca heeft geschreven in bericht
<6umi3k$nn...@nnrp1.dejanews.com>...

Quote
>hello;

>I am using Delphi 2 and trying to read a simple test file a line at a time.
I
>have written the code (see below) as outlined in the hlpe files and manual.
>but the problem occurs that whenever i try to run the program I get an
error
>at the "Reset(R):" line saying missing operator or colon!.. i cannot figure
>out what i am doing wrong or how to correct this. I hope someone can help.
>procedure..... var R :TextFile; name : string; begin  AssignFile(R,
>'drivers.txt');  Reset(R);  Readln (R,name);  dr1name.Caption := name;
>Readln (R,name);  dr2name.Caption := name;  Readln (R,name);
dr3name.Caption
>:= name;  CloseFile(R); end;

>thanks Greg Hounsell PS I wrote to this file on another form with no probs
>usng the same basic format but with proper coding of course :)

>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Other Threads