Autor Beitrag
thorstenf01
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 60

Win XP
D5 enterprise
BeitragVerfasst: So 27.07.03 20:01 
Hy!
Ich habe ein Problem mit diesem Teil einer Pascal Ausgabe:
Die Ausgabe soll in Delphi in eine 'Listbox' geschrieben werden. 'jk' und 'Dat' sind vom Typ Integer und müssen noch in ein String gewandelt werden. Kann mir jemand helfen?
ausblenden Quelltext
1:
writeln(jk:4,Dat:6,Monat:5, gSchatA[jk]:10:2,' Uhr', gSchatE[jk]:14:2,'Uhr', gBela[jk]:13:1,' min');					

Danke im voraus...
Gruß
Thorsten
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 28.07.03 09:11 
Hallo!

Ich hab deine Frage nicht wirklich vestanden. Deshalb kann ich nur raten:

thorstenf01 hat folgendes geschrieben:
Die Ausgabe soll in Delphi in eine 'Listbox' geschrieben werden.

Neue Zeilen fügst du mit Items.Add in die Listbox ein:
ausblenden Quelltext
1:
ListBox1.Items.Add ('Neue Zeile');					


thorstenf01 hat folgendes geschrieben:
'jk' und 'Dat' sind vom Typ Integer und müssen noch in ein String gewandelt werden.

Dafür kannst du IntToStr benutzen.

Gruß
Tino
thorstenf01 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 60

Win XP
D5 enterprise
BeitragVerfasst: Mo 28.07.03 09:39 
Hallo Tino!
Was mir große Probleme bereitet, ist der Inhalt der Klammer, also
die Umwandlung von
ausblenden Quelltext
1:
(jk:4,Dat:6,Monat:5, gSchatA[jk]:10:2,' Uhr', gSchatE[jk]:14:2,'Uhr', gBela[jk]:13:1,' min')					

in den Delphi Code.
Gruß
Thorsten
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 28.07.03 11:45 
Hallo,

was soll denn da für ein Delphi-Code rauskommen? Verstehe ich nicht.

Was hat z. b. "jk:4" zu bedeuten oder "Dat:6" oder "Monat:5"? Oder ist das alles nur ein einfacher String der in einer Listbox angefügt werden soll?

Beschreib einfach mal welche Informationen du zur Verfügung hast (Variablen oder so) und wie der String aufgebaut sein soll.

Gruß
Tino
thorstenf01 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 60

Win XP
D5 enterprise
BeitragVerfasst: Mo 28.07.03 13:42 
Hy!
Ich habe "write(' ')" und writeln(' ')" durch ListBox1.Items.Add(' ')
ersetzt, ein paar Variablen namentlich verändert.
Ansonsten habe ich den Code aus Pascal übernommen.
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
...
var   Dat                          :integer;
        Monat                        :string[4];
        SchatA, SchatE, Bel, SchatgA, SchatgE, Belg, Zt    :array[1..366] of real;
...
procedure TForm3.Button5Click(Sender: TObject);
var
  jk, jj, ss, kk   : integer;
  min, Sum, Sum1, Dif                        : real;
 begin
  ListBox1.Items.Clear;
  ListBox1.Items.Add(' ');
  ListBox1.Items.Add('                    Schattenwurfdetektor');
  ListBox1.Items.Add(' ');
  ListBox1.Items.Add('Tag    Datum    Abschattungsbeginn     Abschattungsende    Belastungszeit');
  ListBox1.Items.Add(' ');
  ListBox1.Items.Add('__________________________________________________________________________');
   kk:=0;
      for jk:=1 to 366 do begin
      if SchatgA[jk]>0 then begin
      kk:=kk+1;
      Tag:=jk; Sonnenstand(Tag); AU_der_Sonne(Tag);
      tA:=0.1*SchatA[jk]+0.9*SchatgA[jk];
               Lage_Ellipse(tA);
               Dif:= abs(SchatgA[jk]-tg);
      if (Dif < 0.00025) or (tg=0) then SchatgA[jk]:=tg  else begin
      repeat
               tA:=SchatgA[jk]; Lage_Ellipse(tA);
               Dif:=abs(SchatgA[jk]-tg);
               SchatgA[jk]:=tg;
      until Dif < 0.00025;  end;

      tA:=0.1*SchatE[jk]+0.9*SchatgE[jk];
               Lage_Ellipse(tA);
               Dif:= abs(SchatgE[jk]-tg);
      if (Dif < 0.00025) or (tg=0) then SchatgE[jk]:=tg else begin
      repeat
               tA:=SchatgE[jk]; Lage_Ellipse(tA);
               Dif:=abs(SchatgE[jk]-tg);
               SchatgE[jk]:=tg;
      until Dif < 0.00025;  end;

      if SchatgA[jk]=0 then begin
                       if SchatgE[jk] >0 then SchatgA[jk]:=SchatgE[jk]; end;
      if SchatgE[jk]=0 then begin
                       if SchatgA[jk] >0 then SchatgE[jk]:=SchatgA[jk]; end;
      Bel[jk]:=(SchatE[jk]-SchatA[jk])*60;
      Belg[jk]:=(SchatgE[jk]-SchatgA[jk])*60;

      {Zeitumwandlung in Stunden und Minuten}
      ss:=trunc(SchatgA[jk]);
      min:=round((SchatgA[jk]-SS)*60);
      if min=60 then begin ss:=ss+1; min:=0; end;
      SchatgA[jk]:=ss+min/100;
      ss:=trunc(SchatgE[jk]);
      min:=round((SchatgE[jk]-ss)*60);
      if min=60 then begin ss:=ss+1; min:=0; end;
      SchatgE[jk]:=ss+min/100;

      Tag:=jk;
      Zeit(Tag);

      jj:=Trunc(kk/20);
      if jj= kk/20 then readln;
      ListBox1.Items.Add(' ');
      ListBox1.Items.Add(jk:4, Dat:6, Monat:5, SchatgA[jk]:10:2,' Uhr', SchatgE[jk]:14:2,' Uhr', Belg[jk]:13:1,' min');

                                                                    end;end;
  Sum:=0;
  Sum1:=0;
  for jk:=1 to 366 do begin
    Sum:=Sum+Bel[jk];
    Sum1:=Sum1+Belg[jk]; end;
  JaBe:=Sum/60;
  JaB:=Sum1/60;
  ListBox1.Items.Add(' ');
  ListBox1.Items.Add('Jahresbelastung:', JaB:8:1,' Stunden', JaBe:14:1 );
  readln;
end;

Dank nocheinmal
Gruß
Thorsten
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mo 28.07.03 20:20 
die :4 sind formatierungen

wenn mich meine Erinnerungen nicht täuschen sah ein write aufruf optional so aus
ausblenden Quelltext
1:
write(IrgendeineZahl:b:n)					

:b gibt die Breite eines Feldes an, in das die Zahl rechtsbündig ausgegeben werden soll
:n hat was mit den Festkommadarstellung zu tun, macht nur Sinn bei Fließkommazahlen
Bsp mit write(123.4:12:3) kommt ungefähr sowas raus 123.400

gibts aber nicht im zusammenhang mit Listbox.items.add. Du kannst aber auf Format-Funktionen Suche in: Delphi-Forum, Delphi-Library FORMAT ausweichen.

die readln sind immer noch drin :roll:

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)