DelphiBasics
Output
Variable
Defines the standard output text file System unit
var Output : TextFile;
Description
The Output variable is predefined by Delphi to refer to the standard text output file.
 
This is normally the console, but may be overriden to any file using the Assign statement.
 
Output is used in the text file Write, WriteLn and Seek routines. It may be omitted in these commands however, since it is the default file.
Related commands
$AppTypeDetermines the application type : GUI or Console
InputDefines the standard input text file
WriteWrite data to a binary or text file
WriteLnWrite a complete line of data to a text file
 Download this web site as a Windows program.




 
Example code : Read and write to the console
program Project1;

{$AppType CONSOLE}

uses
  SysUtils;

var
  name : string;

begin
  // A console application has the console Input and Output
  // assigned and opened on our behalf.
  WriteLn(Output, 'Please enter your name');
  ReadLn(Input, name);

  // And we do not even have to refer to these file names
  WriteLn('Your name is '+name);
  WriteLn('');
  WriteLn('Press enter to exit');
  ReadLn(name);
end.
  Example console output :
  
  Please enter your name
  Joe Bloggs
  Your name is Joe Bloggs
  
  Press enter to exit
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page