TIP: Click on subject to list as thread! ANSI
echo: delphi
to: JUD MCCRANIE
from: MIGUEL SIGENZA
date: 1997-07-29 14:13:00
subject: Re: READ A TEXT FILE

 JM> How do you read a text file in Delphi 3?  That is, what is
 JM> the equivalent of
 
 JM> var f : text;
 JM>     line : string;
 
 JM> ...
 
 JM> assign( f, 'text.dat');
 JM> reset( f);
 JM> readln( f, line);
 JM> close( f);
        Hi, Jud...
        you can do it of two ways:
1)      var
          f:textfile:
          line:string;
        [...]
        assignfile(f,'text.dat');
        reset(f));
        while not(eof(f)) do       { while not end of file do}
          begin
            readln(f,line);      {read a line}
            memo1.lines.add(line); {add the line to the Memo component}
          end;
        closefile(f);
2)      The way easiest is:
        ->        memo1.lines.loadfromfile('text.dat');
        Only one line and you have the same file in a Memo component.
        Remember that if you want to clear the component use:
        ->        memo1.clear;
                That`s all folks !!!
Esta es la va del futuro Ŀ         Miguel Sigenza  
para el virus Windows 95  9        E-Mail: m-siguenza@bdd.unizar.es
ѳ5  
ϳWindows ܳ
                          
... Mensaje con sonido, configurado actualmente para: No Sound.
---
---------------
* Origin: Lawrence de Arabia: Esta' todo aqui' (2:342/13)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.