Read a file line by line: Difference between revisions

m
→‎{{header|Pascal}}: assign Outputfile not InputFile as in and output ( copy and paste ) File is binary file Text for Textfiles
m (Regularize non-standard header markup)
m (→‎{{header|Pascal}}: assign Outputfile not InputFile as in and output ( copy and paste ) File is binary file Text for Textfiles)
Line 2,468:
 
=={{header|Pascal}}==
{{Works with|Free Pascal}}
<lang pascal>(* Read a file line by line *)
Works for text files. "testin.txt" must exist in directory of program and you must have read/write access. No IO-Checks.
<lang pascal>(* Read a text-file line by line *)
program ReadFileByLine;
var
InputFile,OutputFile: Filetext;
TextLine: String;
begin
Assign(InputFile, 'c:\testin.txt');
Reset(InputFile);
Assign(InputFileOutputFile, 'c:\testout.txt');
Rewrite(InputFileOutputFile);
while not Eof(InputFile) do
begin
ReadLn(InputFile, TextLine);
(* do someting with TextLine *)
WriteLn(OutputFile, TextLine)
end;
Anonymous user