Read And Display a File
 


program Read_And_Display;

var Chicken : text;
Name_Of_File_To_Input : string[12];
Line_Count : integer;
Big_String : string[80];

begin (* main program *)
Write('Enter input file name ');
Readln(Name_Of_File_To_Input);
Assign(Chicken,Name_Of_File_To_Input);
Reset(Chicken);

Writeln;
Writeln('Program listing with character count per');
Writeln('line and total line count');
Writeln;

Line_Count := 0;
while not Eof(Chicken) do begin
Readln(Chicken,Big_String);
Writeln(Length(Big_String):5,' ',Big_String);
Line_Count := Line_Count + 1;
end;
Close(Chicken);
Writeln;
Writeln('The line count is ',Line_Count:3);
end. (* of program *)


Result of execution

(The selected file is displayed on the monitor)

(c) Shilpa Sayura Foundation 2006-2017