Autor Beitrag
beljo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 129



BeitragVerfasst: Mi 12.07.06 09:00 
Hallo Leute,
bin gerade dabei eine Stringliste abzulegen, funzt auch.
Leider bin ich mit dem Layout unzufrieden.
zuzeit wird es so ausgegeben :

Leistung: in kW Nr.:0___:0.00
Leistung: in kW Nr.:1___:5.02
Leistung: in kW Nr.:2___:10.05
Leistung: in kW Nr.:3___:180.26
Ich hätte es aber lieber so: Die underlines sollen Leerzeichen symbolisieren.

Leistung: in kW Nr.:0___:__0.00
Leistung: in kW Nr.:1___:__5.02
Leistung: in kW Nr.:2___:_10.05
Leistung: in kW Nr.:3___:180.26

Hier ist mein Quellcode für diese Programmzeile.
ausblenden Delphi-Quelltext
1:
2:
3:
repeat
  anweisung.Add('Drehmoment m in Nm :'+IntToStr(i)+'   :'+FloatToStr(m.Zahlen[i*10]));
  i:=i+1;//...

Wie kann ich dies ohne viel Aufwand realiseren. Ich möchte echt nicht jeden einzelnen Wert überprüfen ob er ein Einer Hundeter oder Tausender ist, habt ihr vielleicht eine einfache Lsg. parrat?
crowley
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 406

Win XP, Win Vista, Mandriva, Ubuntu
Delphi 4-8, Delphi 2006, Delphi 2007
BeitragVerfasst: Mi 12.07.06 09:05 
schau dir mal den format-befehl an

ausblenden Delphi-Quelltext
1:
  Format('%-.5s', [mystring])					


oder so ähnlich sollte deinen "mystring" mit Leerzeichen auf der linken Seite auf 5 Zeichen auffüllen

C.
beljo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 129



BeitragVerfasst: Mi 12.07.06 09:49 
Naja mit der Delphihilfe hab ich es nicht so ;-)
Leider funzt es nicht so richtig.
ausblenden Delphi-Quelltext
1:
anweisung.Add('Drehzahl n in 1/min Nr.:'+IntToStr(i)+'   :'+Format('%-.5s',[FloatToStr(Zahlen[i*10])]));					

Weis jemand wieso es nicht klappt?
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 12.07.06 09:54 
Hallo,

eventuell weil Dein bisheriger Code so aussieht:
ausblenden Delphi-Quelltext
1:
anweisung.Add('Drehmoment m in Nm :'+IntToStr(i)+'   :'+FloatToStr(m.Zahlen[i*10]));					

Was klappt nicht? Fehlermeldung?

Es geht auch direkt ohne den Umweg über einen String:
ausblenden Delphi-Quelltext
1:
anweisung.Add(Format('Drehmoment m in Nm:%3d   :%8.2f',[i,m.Zahlen[i*10]]));					

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
beljo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 129



BeitragVerfasst: Mi 12.07.06 10:06 
Hallo,
@Lannes: also zum prob. hab ich ein neues projekt angelegt deshalb die Sache mit dem m.zahlen und zahlen.
Aber egal,
jedenfalls hat dein Vorschlag bestens gefunzt.
Danke
// Edit: eine Feherlmeldung beim letzten Source gab es keine veränderung bei der Ausgabe und keine Fehlermeldung