Position the cursor in the console/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Position the cursor in the console/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Zurück zur [[Console/de|Konsolenseite]]. | |
| 2 | + | ||
| 3 | + | # Den Cursor in der Konsole positionieren | |
| 4 | + | ||
| 5 | + | Dieser Artikel dient der Konsolen- / Terminalprogrammierung unter Windows und Linux.\ | |
| 6 | + | Mit dem Befehl GotoXY kann in der Konsole / Terminal der Cursor an die gewünschte Stelle gesetzt werden.\ | |
| 7 | + | ||
| 8 | + | ``` pascal | |
| 9 | + | program project1; | |
| 10 | + | ||
| 11 | + | {$mode objfpc}{$H+} | |
| 12 | + | {$IMPLICITEXCEPTIONS OFF} | |
| 13 | + | ||
| 14 | + | uses | |
| 15 | + | Crt; | |
| 16 | + | ||
| 17 | + | begin | |
| 18 | + | // Um auf der Konsole Text zu positionieren, sollte man die Konsolenausgaben | |
| 19 | + | // der vorhergehenden Programme löschen. | |
| 20 | + | // Das geschieht mit dem Befehl ClrScr. | |
| 21 | + | ClrScr; | |
| 22 | + | ||
| 23 | + | // Positioniert den Cursor in Spalte 1, Zeile 5 | |
| 24 | + | GOTOXY(1,6); | |
| 25 | + | Write('Hallo'); | |
| 26 | + | ||
| 27 | + | // Positioniert den Cursor in Spalte 8, Zeile 1 | |
| 28 | + | GOTOXY(8,1); | |
| 29 | + | Write('Welt'); | |
| 30 | + | // Setzt den Cursor an das Ende der Programmausgabe. | |
| 31 | + | // Damit erscheint die Komandozeile / der Prompt nicht mitten | |
| 32 | + | // in der eigenen Programmausgabe | |
| 33 | + | GotoXY (1,7); | |
| 34 | + | end. | |
| 35 | + | ``` | |
| 36 | + | ||
| 37 | + | \ | |
| 38 | + | Die Ausgabe sieht unter Windows so aus:\ | |
| 39 | + | ||
| 40 | + | Welt | |
| 41 | + | ||
| 42 | + | Hallo | |
| 43 | + | ||
| 44 | + | C:\Programmierung\Test3> | |
| 45 | + | ||
| 46 | + | \ | |
| 47 | + | Die Ausgabe sieht unter Linux so aus:\ | |
| 48 | + | ||
| 49 | + | Welt | |
| 50 | + | ||
| 51 | + | Hallo | |
| 52 | + | /home/gast/Dokumente/Programmierung/Lazarus/Test3$ | |
| 53 | + | ||
| 54 | + | --- | |
| 55 | + | *From the Free Pascal wiki, page "Position the cursor in the console/de", as it stood on 2020-02-23 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).* |
