Output to the Monitor

The short program WriteToConsole demonstrates a few useful features that can be used with write and writeln statements.

  • You can use the statement writeln; to give an empty line. Alternatively, type #13#10 for each carriage-return-line-feed combination required.
  • An apostrophe is the same character as the single quote used to mark the beginning and end of a string of text. In order to show an apostrophe within a quoted string, type two consecutive apostrophes.
  • The £ character on the keyboard, when used in a quoted string, may not show up correctly. To show the £ character reliably, use CHR(156) (or, in its abbreviated format, #156).
  • Use #8 for a backspace and #9 for a tab.
program WriteToConsole;
  {$APPTYPE CONSOLE}
uses
  SysUtils;
var
   i: integer;
begin
  writeln('Jim''s laptop cost ', CHR(156), '800.'#13#10); //Jim's, £ sign, CR/LF
  write(#9'Program ending: ');  //Tab
  for i:= 5 downto 1 do
    begin
      write(i);
      sleep (1000);
      write(#8);   //Backspace so that digits overwrite each other
    end;
end.

Programming - a skill for life!

Input from keyboard and file and output to monitor, file and printer