![]() |
Format-Strings
Hallo,
montag morgen und schon die ersten probleme ;-) Mein Problem: habe eine zahl 2..3 stellig und die sall asl string der form dargestellt werden: für 124 : '\124' das ist ja kein wirkliches problem aber... für 28: '\028' hier ist die null das problem, ich möchte nicht noch eine zusätzliche abfrage machen, wenn es geht, also hab ich mich um format-strings bemüht...
Delphi-Quellcode:
aber es funzt nicht :wall: obwohl in der oh steht ...
result:=result+format('\%3d',[ZeichenNr]) // ersetzte Zeichen
Zitat:
|
Re: Format-Strings
Du hast den Punkt vor der 3 vergessen.
|
Re: Format-Strings
Hi,
also bei mir steht in der Hilfe, dass die fehlenden Stellen mit Leerzeichen aufgefüllt werden. Das bei entsprechender Ausrichtungsangabe vor oder nach dem String. Mit "0" ist da nichts! Verwende sonst FormatFloat. Hier kannst du als FormatString '000' eintragen und es funzt wie gewollt. Gruß oki |
Re: Format-Strings
Oooops,
war langsammer als MathiasSimmack und er hat auch noch recht. Gruß oki |
Re: Format-Strings
thx at all, so klappts auch mit den nullen :thuimb:
Delphi-Quellcode:
result:=result+format('\%.3d',[ZeichenNr])
|
Re: Format-Strings
Das ist vielleicht das groesste Problem von Format() das es die Format-Strings von C nicht voll uebernommen hat.
Ich hatte schon oefters den Wunsch das mal zu implementieren, aber wenn man den Standard (ja das ist inzwischen standardisiert) liest dann ueberlegt man es sich immer wieder. |
Re: Format-Strings
Zitat:
|
Re: Format-Strings
Es ist nur eine unvollständige "Übersetzung" der String-Formatierungs-Möglichkeiten, wie sie aus C bei printf zum Beispiel möglich sind. das wollte Robert damit wohl sagen.
|
Re: Format-Strings
Genau. Delphi und C sind auch noch dezent inkompatibel bei den Format-Strings.
Vielleicht koennten wir mal ein Projekt dazu anleiern. |
Re: Format-Strings
Zitat:
Delphi-Quellcode:
System.String.Format('{0} - {1} ({2,2:00}:{3,2:00} min)'
,['Filter', 'Welcome to the Fold', 7, 40]);
Code:
String[b][color=#ff0000].[/color][color=#3600aa]Format[/color][color=#ff0000]([/color][/b][color=#ad0000]"{0} - {1} ({2,2:00}:{3,2:00} min)"[/color]
[b][color=#ff0000],[/color][/b][color=#3600aa]new[/color] [b]Object[color=#ff0000][] {[/color][/b][color=#ad0000]"Van Halen"[/color][b][color=#ff0000], [/color][/b][color=#ad0000]"Running with the devil"[/color][b][color=#ff0000], [/color][/b][color=#ad00bb]3[/color][b][color=#ff0000], [/color][/b] [color=#ad00bb]34[/color] [b][color=#ff0000]});[/color][/b] |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:04 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz