Difference between revisions of "Str/de"
From Free Pascal wiki
Jump to navigationJump to searchm (Fixed syntax highlighting; deleted category included in page template) |
|||
(One intermediate revision by one other user not shown) | |||
Line 2: | Line 2: | ||
=Str= | =Str= | ||
+ | |||
==Beschreibung== | ==Beschreibung== | ||
Line 8: | Line 9: | ||
==Beispiel== | ==Beispiel== | ||
− | <syntaxhighlight> | + | |
+ | <syntaxhighlight lang=pascal> | ||
var | var | ||
s: string; | s: string; | ||
Line 16: | Line 18: | ||
begin | begin | ||
i := 123; | i := 123; | ||
− | Str(i, s); | + | Str(i, s); // ohne Formatierung |
WriteLn(s); | WriteLn(s); | ||
Str(i: 8, s); // String formatieren | Str(i: 8, s); // String formatieren | ||
Line 22: | Line 24: | ||
f := 123.456; | f := 123.456; | ||
− | Str(f, s); | + | Str(f, s); // ohne Formatierung |
WriteLn(s); | WriteLn(s); | ||
Str(f: 8: 4, s); // String formatieren | Str(f: 8: 4, s); // String formatieren | ||
+ | WriteLn(s); | ||
+ | Str(f: 8, s); // String als komplettes formatieren | ||
WriteLn(s); | WriteLn(s); | ||
end. | end. | ||
Line 30: | Line 34: | ||
==Siehe auch:== | ==Siehe auch:== | ||
+ | |||
* [[Val/de|Val]] - String in numerischen Wert konvertieren. | * [[Val/de|Val]] - String in numerischen Wert konvertieren. | ||
− | |||
− | |||
− | |||
− |
Latest revision as of 02:18, 28 February 2020
│
Deutsch (de) │
English (en) │
русский (ru) │
Str
Beschreibung
Mit Str, kann man einen numerischen Wert in einen String konvertieren. Es ist sogar mittels : Breite: Dezimal eine Formatierung des Stringes möglich, siehe Beispiel.
Hinweis: Bei Float-Typen muss beachtet werden, das immer ein Punkt als Dezimaltrenner ausgegeben wird, egal wie die Ländereinstellungen des OS eingestellt sind.
Beispiel
var
s: string;
i: integer;
f: single;
begin
i := 123;
Str(i, s); // ohne Formatierung
WriteLn(s);
Str(i: 8, s); // String formatieren
WriteLn(s);
f := 123.456;
Str(f, s); // ohne Formatierung
WriteLn(s);
Str(f: 8: 4, s); // String formatieren
WriteLn(s);
Str(f: 8, s); // String als komplettes formatieren
WriteLn(s);
end.
Siehe auch:
- Val - String in numerischen Wert konvertieren.