Sign in Join
Wiki copytemporary

Position the cursor in the console/de

Zurück zur Konsolenseite.

Den Cursor in der Konsole positionieren

Dieser Artikel dient der Konsolen- / Terminalprogrammierung unter Windows und Linux.
Mit dem Befehl GotoXY kann in der Konsole / Terminal der Cursor an die gewünschte Stelle gesetzt werden.\

pascal
program project1;

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

uses
  Crt;

begin
  // Um auf der Konsole Text zu positionieren, sollte man die Konsolenausgaben
  // der vorhergehenden Programme löschen.
  // Das geschieht mit dem Befehl ClrScr.
  ClrScr;

  // Positioniert den Cursor in Spalte 1, Zeile 5
  GOTOXY(1,6);
  Write('Hallo');

  // Positioniert den Cursor in Spalte 8, Zeile 1
  GOTOXY(8,1);
  Write('Welt');
  // Setzt den Cursor an das Ende der Programmausgabe.
  // Damit erscheint die Komandozeile / der Prompt nicht mitten
  // in der eigenen Programmausgabe
  GotoXY (1,7);
end.

Die Ausgabe sieht unter Windows so aus:\

pascal
Welt
pascal
Hallo
pascal
C:\Programmierung\Test3>

Die Ausgabe sieht unter Linux so aus:\

pascal
Welt
pascal
Hallo
/home/gast/Dokumente/Programmierung/Lazarus/Test3$

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.

Revision 2, 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.