Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 2/Formatting output/de

Deutsch · English · Français · Български · 中文(中国) · 日本語

2C - Formatierte Ausgabe

(Autor: Tao Yue, Übersetzung ins Deutsche)

Die Formatierung der Ausgabe ist recht einfach. Verwende für jeden Bezeichner oder Literalwert in der Argumentliste:

pascal
Value : field_width

Die Ausgabe erfolgt rechtsbündig in einem Feld der angegebenen ganzzahligen Breite. Wenn die Breite für die Daten nicht lang genug ist, wird die Breitenangabe ignoriert und die Daten werden in ihrer Gesamtheit angezeigt (mit Ausnahme der realen Werte - siehe unten).

Angenommen, wir hätten:

pascal
write ('Hi':10, 5:4, 5673:2);

Die Ausgabe wäre (das sind acht Leerzeichen vor dem Hi und drei Leerzeichen danach):

text
        Hi   55673

Für reelle Werte kannst Du die oben genannte Syntax verwenden, um die wissenschaftliche Notation in einer bestimmten Feldbreite darzustellen, kannst Du sie in eine Festkomma-Notation umwandeln:

pascal
Value : field_width : decimal_field_width

Die Feldbreite ist die Gesamtfeldbreite einschließlich des Dezimalteils. Der gesamte Zahlenteil wird immer vollständig angezeigt, wenn Du also nicht genügend Platz zugewiesen hast, wird er trotzdem angezeigt. Wenn jedoch die Anzahl der Dezimalstellen die angegebene Dezimalfeldbreite überschreitet, wird die Ausgabe auf die angegebene Anzahl von Stellen gerundet dargestellt (wobei die Variable selbst nicht verändert wird).

pascal
write (573549.56792:20:2);

würde so aussehen (mit 11 Leerzeichen davor):

text
           573549.57

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 2/Formatting output/de", as it stood on 2022-08-20 after a change by Kai Burghardt, 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 3, last changed by WikiArchive .

Edited on wiki.freepascal.org by 3 people, 2018–2022

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
GenosseCreated page
TrevFixed syntax highlighting (minor)
Kai BurghardtKai Burghardt moved page Formatting output/de to Basic Pascal Tutorial/Chapter 2/Formatting output/de: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: Perma... (minor)
Kai Burghardtbypass redirects [cf. discussion]
Kai Burghardtbypass language bar/categorization template redirect [cf. discussion] (minor)

Talk about this page

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