Sign in Join
Wiki copytemporary

read from the console/de

Zurück zur Konsolenseite.

Eingaben an der Konsole

Dieser Artikel dient der Konsolen- / Terminalprogrammierung unter Windows und Linux.

Wenn Sie also eine Anwendung für Konsole / Terminal erstellen und Sie wollen, dass das Programm auch Tastatureingaben an nimmt, dann haben Sie drei Befehle zur Auswahl.

Die Befehle Read und ReadLn arbeiten gleich. Beide Befehle lesen solange von der Tastatur ein, bis die Taste <Return> gedrückt wird. Alle vom Anwender eingegebenen Zeichen werden an der Konsole / Terminal ausgegeben. Der Befehl ReadKey liest genau ein Zeichen von der Tastatur. Dieses Zeichen wird nicht an der Konsole ausgegeben.
Beispiel für die Befehle Read, ReadLn:

pascal
program Project1;

{$mode objfpc}{$H+}
{$IMPLICITEXCEPTIONS OFF}

uses
  crt;

  var
    strEingabe: string;

begin

  Write('Bitte Eingeben');
  ReadLn(strEingabe);

end.

Beispiel für den Befehl ReadKey:

pascal
program Project1;

{$mode objfpc}{$H+}
{$IMPLICITEXCEPTIONS OFF}

uses
  crt;

  var
    chrEingabe: Char;

begin

  Write('Bitte Eingeben');
  chrEingabe := ReadKey;

end.

From the Free Pascal wiki, page "read from the console/de", as it stood on 2020-02-24 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Edited on wiki.freepascal.org by 2 people, 2014–2020

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
OlafCreated page
Olaf (minor)
Olaf (minor)
TrevFixed syntax highlighting; removed categories included in template (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.