Home  |  Delphi .net Home  |  System.Console  |  Read Method
  
Read  
Method  
Read a character from the Standard Input Stream
Console Class
System NameSpace
NotCF1.  Function Read : Integer; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
The Read method reads the next character from the standard input stream. It returns -1 if the input stream has terminated. For example, when the user hits Ctrl-C on the console.
 
Note that the value returned is cast to an Integer. You should cast it to a Char to display it.
 
Unlike the ReadLine method, the carriage return (13)/line feed characters (10) are returned.
Notes
Static methods are not methods of an object - they are simply class functions or procedures available at any time.
Microsoft MSDN Links
System
System.Console
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  letter : Integer;
  text   : String;
  done   : Boolean;

begin
  Console.WriteLine('Please enter your name : ');

  text   := '';

  // We are looking for line throw - indicates that user hit enter
  repeat
    letter := Console.Read;
    text   := text + char(letter);
  until letter = 10;

  Console.Write('You entered : ' + text);

  Console.ReadLine;
end.
   Please enter your name :
   Neil
   You entered : Neil
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author