DelphiBasics
Input
Variable
Defines the standard input text file System unit
var Input : TextFile;
Description
The Input variable is predefined by Delphi to refer to the standard text input file.
 
This is normally the console, but may be overriden to any file using the AssignFile statement.
 
Input is used in the text file Read, ReadLn 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
OutputDefines the standard output text file
ReadRead data from a binary or text file
ReadLnRead a complete line of data from 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