Retrocomputing

List a text file to standard output

A simple program to show how Pascal handles end of lines in text files. A similar example is shown in Pascal User Manual and Report by by Kathleen Jensen and Niklaus Wirth.

OS-9 Pascal edition

{ List a text file to standard output
  This uses a special array called 'SYSPARAM' to pass arguments from the
  calling shell. The array is predefined as:
  sysparam : ARRAY [0..79] OF char;
  This is a feature of OS-9 Pascal and is not a standard Pascal function.
}
program list(input);

var
  listfile: text;
  ch: char;
begin
  reset(listfile, sysparam);
  while not eof(listfile) do
    begin
      while not eoln(listfile) do
        begin
          read(listfile, ch);
          write(ch)
        end;
      readln(listfile);
      writeln
    end;
  close(listfile);
end.