[fpc-pascal]dumb question
Jilani Khaldi
jilani.khaldi1 at virgilio.it
Mon Aug 2 10:14:11 CEST 2004
Swh8204 at aol.com wrote:
> Ok, guys. it's only been like 15 years since I have written any
> pascal code. Can someone please help me with syntax for opening a
> file so that I can read variable length lines of text from it, then
> output to another file. Running in DOS on an x86 machine. Thank you.
>
Hi Jason,
procedure ReadFile(const FileName: string);
var
f: TextFile;
st: string;
begin
assignfile(f,FileName);
reset(f);
while not eof(f) do
begin
readln(f, st); // here you are reading one line from the file at
every loop
// do what you want with st
writeln(st); // for example
end;
closefile(f);
end;
// main
begin
ReadFile('c:\autoexec.bat');
end.
--
Jilani
More information about the fpc-pascal
mailing list