read from the console/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: read from the console/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Zurück zur [[Console/de|Konsolenseite]]. | |
| 2 | + | ||
| 3 | + | # Eingaben an der Konsole | |
| 4 | + | ||
| 5 | + | Dieser Artikel dient der Konsolen- / Terminalprogrammierung unter Windows und Linux. | |
| 6 | + | ||
| 7 | + | 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. | |
| 8 | + | ||
| 9 | + | - Read | |
| 10 | + | - ReadLn | |
| 11 | + | - ReadKey | |
| 12 | + | ||
| 13 | + | 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.\ | |
| 14 | + | Beispiel für die Befehle **Read**, **ReadLn**: | |
| 15 | + | ||
| 16 | + | ``` pascal | |
| 17 | + | program Project1; | |
| 18 | + | ||
| 19 | + | {$mode objfpc}{$H+} | |
| 20 | + | {$IMPLICITEXCEPTIONS OFF} | |
| 21 | + | ||
| 22 | + | uses | |
| 23 | + | crt; | |
| 24 | + | ||
| 25 | + | var | |
| 26 | + | strEingabe: string; | |
| 27 | + | ||
| 28 | + | begin | |
| 29 | + | ||
| 30 | + | Write('Bitte Eingeben'); | |
| 31 | + | ReadLn(strEingabe); | |
| 32 | + | ||
| 33 | + | end. | |
| 34 | + | ``` | |
| 35 | + | ||
| 36 | + | Beispiel für den Befehl **ReadKey**: | |
| 37 | + | ||
| 38 | + | ``` pascal | |
| 39 | + | program Project1; | |
| 40 | + | ||
| 41 | + | {$mode objfpc}{$H+} | |
| 42 | + | {$IMPLICITEXCEPTIONS OFF} | |
| 43 | + | ||
| 44 | + | uses | |
| 45 | + | crt; | |
| 46 | + | ||
| 47 | + | var | |
| 48 | + | chrEingabe: Char; | |
| 49 | + | ||
| 50 | + | begin | |
| 51 | + | ||
| 52 | + | Write('Bitte Eingeben'); | |
| 53 | + | chrEingabe := ReadKey; | |
| 54 | + | ||
| 55 | + | end. | |
| 56 | + | ``` | |
| 57 | + | ||
| 58 | + | --- | |
| 59 | + | *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](/wiki-contact).* |
